Comp Theory (2)
Comp Theory (2)
(Theory)
(Two Hours)
Answers to this Paper must be written on the paper provided separately.
You will not be allowed to write during the first 1s" minutes.
. This time is to be spent in reading the question paper.
The time given at the head of this Paper is the time allowed for writing the answers.
om
The intended marksfor questions or parts of questions are given in brackets[].
.c
SECTION A (40 Marks)
Attempt all questions
rz
Question 1.
pe
(a) What are the default values of the primitive data type int and float? (2]
(b) Name any two OOP's principles. [2]
Pa
(e) Name the wrapper classes of char type and boolean type. [2]
Te
Question 2.
Question 3.
(a) State the data type and value of y after the following is executed:
char x='7';
y=Character.isLetter(x);
om
[2]
. (b) What is the function of catch block in exception handling? Where does it
appear in a program? [2]
.c
(c) State the output when the following program segment is executed:
String a ="Sm�phone", b="Graphic A:rt":
rz
String h=a.substring(2,5);
String k= b.substring(8).toUpperCase();
pe
System.out.println(h);
System.out.println(k.equalslgnoreCase(h)); [2]
Pa
(d) The access specifier that gives the most accessibility is �____and the
least accessibility is_,:�·---""------ [2]
(e) (i) Name the mathematical function which is used to find sine of an angle
st
given in radians.
Te
(ii) Name a string function which removes the blank spaces provided in tJ,ie
prefix and suffix of a string. [2]
(f) (i) What will this code print?
int arr[] =new int (5];
System.out.println(arr);
(i) 0 . (ii) value stored in arr[O] (iii) 0000 (iv)garbage value
(ii) Name the keyword which is used to resolve the conflict between method
parameter and instance variables/fields. [2]
2
T l5 861
www.testpaperz.com
(g) State the package that contains the �lass:
(i) BufferedReader
(ii) Scanner. [2]
(h) Write the output of the following program code:
char ch;
int x=97;
do
{
ch= (char) x;
System.out.print(ch + 11 ");
if( x%10=0)
break;
++x;,
om
}while(x<= 100); [2]
(i) Write the Java expressions for:
a2+b2 [2]
2ab
.c
rz
G) If int y=lO then find int z = (++y *(r++ +5)); [2]
pe
The answers in this Section should consist ofthe Programs in either Blue J environment
or any program environment with Java as the base.
st
3
T15 861 Turn Over
www.testpaperz.com
void calculate() - To compute the parking charge at the rate of <3for the first hour or part
thereof, and < 1.50 for each additional hour or part thereof.
void display()-To display the detail
Write a main method to create an object of the class and call the above methods. [I5]
�Question 5.
Write two separate programs to generate the following patterns using iteration (loop) statements:
om
[15]
nuestion 6.
1
Write a program to inpu� and 'store roll numbers, names and marks in·� subjects of n
.c
number students in five single dimensional array and display the remark based on
average marks as given below: ( The maximum marks in the subject are 100)
rz
Average marks = Total Marks
pe
Average marks Remark
85 -100 EXCELLENT
Pa
75-84 DISTINCTION
60-74 FIRST CLASS
40-59 PASS
st
Qu�tion 7.
Desi�n a class to overload a function Joystring() as follows:
(i) void Joystring (String s, char chl, char ch2) with one string argument and two
character arguments that replaces the character argument chi with the
character argument ch2 in the given string s and prints the new string.
Example:
Input value of s ="TECHNALAGY"
ch l='A',
ch2='O'
4
T15 861
www.testpaperz.com
Output : "TECHNOLOGY"
(ii) void J oystring (String s) with one string argument that prints the position of the
first space and the Jast space of the given string s.
Example:
Input value of ="Giouc;l _comp�ti�g n:,.e?J;}�Jnt�ri;i)(t ,'1.asec;l,computing"
Output : First index : 5
Last index : 36
(iii)void Joystring ( String sl, String s2) with two string arguments that combines
the two strings with a space between them and prints the resultant string..
Example:
om
Input value of sl ="COMMON WEALTH".
Input value of s2="GAMES"
Output: COMMON WEALTH GAMES
.c
(use libraryfunctions)
[15]
,-Oiiestion 8.
rz
Write a program to input twenty names in an array. Arrange these_names in descending
pe
order of alphabets, using the bubble sort technique. · i [ 15]
�uestion 9.
Pa
Sample Input n = 15
Sample Output 1,3, 5
(ii) To find and display the factorial of a number input by the user (the factorial of a
non-negative integer n, denoted by n!, is the product of� 4\tegers less than or
equal to n.
Example:
Sample Input n =5
Sample Output 5! = lx2x3x4x5 =120.
For an incorrect choice, an appropriate error message should be displayed. [15]
5
Tl5 861
www.testpaperz.com