2024 Term 1 Comp
2024 Term 1 Comp
2022-23
Time: 2 hrs
General Instructions:
The first 15 minutes should be spent in reading the question paper. And you will not be
allowed to write during the first 15 minutes.
● The time given at the head of this Paper is the time allowed for writing the answers
● Section A is compulsory.
● Attempt any four questions from Section B.
● The intended marks for questions or parts of questions are given in brackets [ ].
● This Question paper contains _8___ printed pages
SECTION A
(40 marks)
Question 1
Select the correct answer to the questions from the given options (Do not copy the
question. Write correct answer only): [20x1=20 Marks]
(i) Automatic conversion of primitive data into an object of wrapper class is called:
a) Auto boxing
b) Un boxing
c) shifting
d) none
(ii) The process by which a class acquires the properties from another class is called:
(a) Polymorphism
(b) Encapsulation
(c) Inheritance
(a) Compiler
(b) Interpreter
(c) Editor
(d) Debugger
(a) true
(b) false
(v) Which of the following packages contain String functions?
(a) Java.Lang
(b) Java.awt
(c) Java.Stirng
(d) java.lang
(vi) Which of the following functions is used to remove the leading and trailing spaces from the
string?
(a) truncate()
(b) trail()
(c) trim()
(d) slice()
(vii) Indicate the error message which displays ,if the following statement is executed:
int a[]={28,32,45,68,12};
System.out.prinln(a[5]);
(a) public
(b) object
(c) main
(d) new
(a) boolean
(b) byte
(c) short
(d) long
(xii) Which of the following is the correct order of the data types in ascending order based on
their memory allocations?
(a) boolean,short,float,byte
(b) byte,boolean,short,float
(c) boolean,byte,short,float
(d) float,short,boolean,byte
(a) >
(b) &&
(c) ==
(d) <=
(a) next()
(b) next.String()
(c) nextLine()
(d) both a & C
(xv) Given : double b=Math.ceil(-3.4)+Math.pow(2,3); What will be the final value stored in the
variable b?
(a) 4
(b) 4.0
(c) 5.0
(d) 5
(a) System.exit(0);
(b) end
(c) continue
(d) break
(a) parseint()
(b) parseString()
(c) valueOf()
(d) none
(a) merge();
(b) join()
(c) connect()
(d) concat()
(a) array;
(b) String
(c) class
(d) int
Question 2 :
Answer the following: [ 10*2=20 Marks]
i. What is the value of y after the execution?
y+= ++y + y-- + --y; when int y=8:
int k=1,i=2;
while(++i<6)
k*=i;
System.out.println(k);
v. What will be the output of the program segment and how many times the loop runs?
int i;
for(i = 5; i > 10; i++)
System.out.println(i);
System.out.println(i * 4);
viii. Write a statement for each to perform the following task on a string:
(i) Extract the second last character of a word stored in the variable wd.
Each program should be written using three comments and variable description
Question 3:
Write a menu driven program to check whether the given number
is i) Neon Number ( A number is said to be ‘Neon’ if sum of the digits of
the square of the number is equal to the number itself. eg 9 is a Neon number).
ii) Perfect Number ( A number is said to be ‘Perfect’ if sum of the
factors,( excluding the number itself) is same as the original number.
eg. 6 is a Perfect number) [15]
Question 4:
Write a program to store 10 students and their phone numbers in two single dimensional
arrays. Enter a name separately and search it in the given list of names. If it is present then
display the name with its telephone number otherwise, display a message “Name not found”.
Use linear search technique. [15]
Question 5:
Write a program in Java to input a sentence. Count and display the frequency of each letter
of the sentence in alphabetical order. [15]
Question 6:
Write a program to accept a word and convert it into lower case, if it is in upper case. Display
the new word by replacing only the vowels with the letter following it.
SampleInput:computer
Sample Output: cpmpvtfr
Question 7:
Write a program to accept a list of 20 integers. Sort the first 10 numbers in ascending order
and next the 10 numbers in descending order by using 'Bubble Sort' technique. Finally, print
the complete list of integers.