Prep2 QP
Prep2 QP
Sanjaynagar, Bengaluru
PREPARATORY EXAMINATION 2
Subject: COMPUTER APPLICATIONS
Grade: 10 Duration: 2 hrs
Section A
(Attempt all questions from this Section.)
Question 1 [20]
Choose the correct answers to the questions from the given options.
(Do not copy the questions, write the correct answers only.)
(i) Which array is represented in the following picture?
(a) public
(b) protected
(c) private
(d) package
(a) 8 bytes
(b) 10 bytes
(c) 11 bytes
(d) 20 bytes
(iv) Operators with higher precedence are evaluated before operators with relatively lower precedence.
Choose the correct order to arrange the operators given below in the order of higher precedence to lower
precedence:
(1) &&
(2) %
(3) >=
(4) ++
(a) public
(b) package
(c) default
(d) subclass
(a) 9.0
(b) 10.0
(c) 11.0
(d) 11
(vii) Which of the following is not true with regards to a switch statement.
(a) checks for an equality between a variable/an expression and the case labels
(b) supports floating-point literals/constants as case labels.
(c) break is used to exit from the switch block.
(d) case labels are unique
(ix) Method prototype for the method round( ) which accept a double argument and returns an integer.
(a) break
(b) continue
(c) return
(d) exit
(xi) Assertion: Integer class can be used in the program without importing a package.
Reason: It belongs to the default package java.lang.
(a) Both Assertion and Reason are true and Reason is a correct explanation of Assertion.
(b) Both Assertion and Reason are true and Reason is not a correct explanation of Assertion.
(c) Assertion is true and Reason is false.
(d) Assertion is false and Reason is true.
(xii) A student executes the following code, which is incorrect to increase the value of a variable ‘num’ by 1.
num =+ 1;
What should be the correct statement(s)?
(1) num++;
(2) num += 1;
(3) num = num + 1;
(4) ++num;
(a) Only 2
(b) 1 and 4
(c) 2 and 3
(d) All the four
(xiii) Conversion of a wrapper class object to its corresponding primitive type is known as
(a) autoboxing
(b) unboxing
(c) implicit conversion
(d) explicit conversion
(a) indexOf( )
(b) lastIndexOf( )
(c) compareTo( )
(d) length( )
(xv) Which principle of Object Oriented Programming does method overloading follow?
(a) Abstraction
(b) Encapsulation
(c) Polymorphism
(d) Inheritance
(a) &&
(b) ||
(c) !
(d) ++
(a) Only 1
(b) Both 1 and 2
(c) Both 2 and 3
(d) All of them
(a) for
(b) while
(c) do…while
(d) switch
(xx) Name the type of error that occurs for the following statement:
System.out.println(Math.sqrt(25 – 50));
Question 2 [20]
(i) Rewrite the following code using simple if statement:
if(students.equals(“mine”))
System.out.println(“BEST”);
else if(students.equals(“MINE”))
System.out.println(“BEST”);
(iv) How many times will the following loop executes? Write the output of the code.
int x = 10;
while(true)
{
System.out.println(x++ * 2);
if(x%3 == 0)
Break;
}
(vii) The output of a which extracts a part of the string “SITHARAMAN” is as follows:
(a) “RAM”
(b) “RAMAN”
Write appropriate Java statements to get the above outputs.
(viii) Arjun has developed a program to display only the alphabets stored in a character array. Below is the
segment of his program, which has some errors. Check for the statements with errors and write the
correct statements.
char ch[ ] = {‘D’, ‘#’, ‘E’, ‘1’, ‘S’};
for(int i=0 ; i<=ch.length( ) ; i++)
if(Character.isAlphabet(ch[i]))
System.out.print(ch[i]);
(ix) Consider the following program segment and answer the questions that follow:
int prime[ ][ ] = { {2, 3, 5, 7} , {11, 13, 17, 19} , {101, 109, 151, 199} };
(a) What is the index of 109?
(b) What is the result of prime[2][3] + prime[0][1]?
Section B
(Answer any four questions from this Section.)
The answers in this section should consist of the programs in either BlueJ environment or any program
environment with Java as the base.
Each program should be written using variable description / mnemonic codes so that the logic of the program
is clearly depicted.
Flowcharts and algorithms are not required.
BufferedReader / DataInputStream should not be used in in the programs.
Question 3 [15]
Define a class named BookFair with the following description:
Member methods:
Write a main method to create an object of the class and call the above member methods.
(a) void method( ) – To display the following pattern using nested loops.
54321
4321
321
21
1
(b) void method(int num) – To check and display whether the integer num is a prime number or not.
A number is said to be a prime number if it has only two factors (i.e., 1 and the number itself)
Example:
num = 13
(c) boolean method(String str, char ch) – To check for the character ch in a string str and return true if
found, otherwise return false.
Example:
str = “daffodils”
ch = ‘a’
Return : true
Question 5 [15]
Write a program to accept a word. Convert the word to uppercase. Count and output the number of consecutive
letters and number of double letter sequences that exist in the word.
[Note: DE, RS and ST are consecutive letters, and OO is a double letter sequence in the word UNDERSTOOD]
Question 6 [15]
Write a program to accept a number from the user and check whether it is a DISARIUM number or not
Note: A number will be called DISARIUM, if sum of its digits powered with their respective position is equal
to the original number.
Members – Amartya Prabhu, Aadhya Uday, Lipyashree N., Sampriti Chaudhury, Deepak V.,
Bhumika J., Aditi Yaragunti
Posts – Head Boy, Head Girl, Sports Captain, CCA Captain, Band Captain, Iris House Captain,
Tulip House Captain
Question 8 [15]
Write a program to input and store the height of your classmates. Sort and display them in descending order
using the selection sort technique.
===========================