XPaper02
XPaper02
Question 2
(i) Evaluate the below Java line: [2]
System.out.println(isUpperCase('Z'));
(ii) Fill in the blanks for the below code to change the array into an array that contains double the parent array. [2]
int[] x = (4, 2, 6, 12, 15, 10, 8};
for(int i = 0; i<x.length;i++)
(l) _ _ _ __
Print((2) );
(iii) The below code snippet checks whether or not any character other than letter or digit is contained in the string
str. Fill in the blanks of the code in order to get the code correct. [2]
boolean ( 1) _ _ _ __
for(int i = 0; i< str.length;i++)
72 Goyal s !CSE Computer Applications Specimen Question Paper with MTP Class 10
(viii) What does the below routine return?
Random rand = new Random ()
· (a) It returns random decimal numbers. (b) It returns random strings.
(c) It returns random integers. (d) It returns a null string only.
(ix) Name which block precedes the block as visible below.
catch ( IOException e)
switch(var)
case 1:
System.out.println("good 11
);
break;
case 2:
System.out.println("better");
break;
case 3:
System.out.println("best");
break;
default:
System.out.println("invalid");
break;
(3) _ _ __ _
break;
if (flag false)
(iv) How would you take the input of a single character from the keyboard in a Java program? [2]
(v) Give any one advantage of using reference type of variables. [2]
(vi) How does the compareToI_gnoreCase (String) method work? [2]
(vii) Evaluate the following Java line: [2]
"Hello".endsWith("lo") && "Conrad".startsWith("con");
(viii) Suppose that you construct a function matchesQ so that it returns true whenever the two strings have some
matching prefix and suffix (of length at least 2) respectively. For the below call of the function, what should
this (assumed) correctly written function ·return? [2]
"abcdef' .matches("retef ');
(ix) Which operator in Java can do the same work as concat(String) of the String class? [2]
(x) Can a class have more than one constructor specified for itself? [2]
----------t~ SECTION B )
Question 3 [15]
Define a class to find the sum of first 75 natural numbers.
Question 4 [15]
Define ·a class to accept a number and check whether it is both divisible by 11 and contains at least a substring
which is also divisible by 11. For example:
99 is divisible by 11 but does not contain a number divisible by 11.
1331 is divisible by 11 and contains 33 that is also divisible by 11.
121 is divisible by 11 but does not contain a substring divisible by 11.
Goyal s !CSE Computer Applications Specimen Question Paper with MTP Class I 0 73
Question 5 (15]
Define a class that accepts a number and outputs the value of n, such that:
a. When the number is even, find n such that 2°.x is the number
b. When the number is odd, find n such that 2°.x + 1 is the number.
Question 6 (15]
Define a class that takes as input an integer n and takes n strings as inputs. Print out all pairs of strings such
that the first string has a suffix which is a prefix of the second string. For example:
dam amicable blessed educated gambler
(darn, amicable) (amicable, blessed), (amicable, educated), (blessed, educated) are such pairs.
Question 7 (15]
Define a class with the following specifications:
Class name: student
Member variables: mo - Roll number
Snarne - Student name
Class - The grade he/she studies in
Prefinal, final - The pre-final and final marks obtained
[Declare the variables using appropriate data types)
Member methods :
void accept() -- accept the details from standard input
void process() -- To decide the students who got more in final than the pre-final.
void print() to print the details as per the following format
Rno sname class pre-final final
void main() -- to create an object of the class and invoke the methods.
Question 8 (15]
Design a class that takes as input an integer n from the user. Take n inputs from the user. Print out the digit
that occurs most frequently in the entire set of numbers entered. For example: for 7 numbers,
12 21 34 46 62 29 98
2 occurs most frequently.
. ~
To get the solution of this Model Test Paper Scan this QR Code
•(!)
CODE-slpL
.
74 Goyal s !CSE Computer Applications Specimen Question Paper with MTP Class 10