LITTLE STAR HIGH SCHOOL
Selection Test 2: 2020-2021
Class: IX Sub: Computer Application (Theory)
Answers to this Paper must be written on the paper provided separately.
You will not be allowed to write during the first 15 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.
This Paper is divided into two Sections.
Attempt all questions from Section A and any four questions from Section B.
The intended marks for questions or parts of questions are given in brackets ().
SECTION A (40 Marks)
Attempt all questions
Question 1:[10]
(a) What are the default values of the primitive data type int and float ? [2]
(b) Name any two OOP’s principles. [2]
(c) What are identifiers ? [2]
(d) Identify the literals listed below: [2]
(i) 0.5 (ii) ‘A’ (iii) false (iv) “a”
(e) Name the type of error (syntax, runtime or logical error) in each case given below: [2]
(i) Division by a variable that contains a value of zero.
(ii) Multiplication operator used when the operation should be division.
Question 2 [10]
(a) Evaluate the value of a. if value of p = 5, q = 19 [2]
int n = (q – p) > (p – q) ? (q – p) : (p – q);
(b) Arrange the following primitive-data types in an ascending order of their size:[2]
(i) char (ii) byte (iii) double (iv) int
(c) What is the value stored in variable res given below :
double res = Math.pow (“345”.indexOf(‘5’), 3); [2]
(d) What is the difference between a break statement and a continue statement when they occur in a
loop ? [2]
(e) What are the values of a and b after the following function is executed, if the values passed are 30
and 50: [2]
void paws(int a, int b)
{
a=a + b;
b=a – b;
a=a – b;
System.out.println (a+ “,” +b);
}
Question 3 [20]
(a) Write a Java expression for the following : [2]
ax5 + bx3 + c
(b) What is the value of xl if x=5 ? [2]
x1 = + +x – x+ + –x
(c) Why is an object called an instance of a class ? [2]
(d) Convert following do-while loop into for loop. [2]
int i = 1;
int d = 5;
do
{
d=d*2;
System.out.println(d);
i+ + ;
} while (i< =5);
Page 1 of 3
(e) Write one difference between / and % operator. [2]
(f) Write the output for the following : [2]
String s= “Today is Test”;
System.out.println(s.indexOf(‘T’));
System.out.println(s.substring(0, 7) + ” ” + “Holiday”);
(g) What are the values stored in variables r! and r2: [2]
(i) double r1=Math.abs(Math.min(-2.83,-5.83));
(ii) double r2=Math.sqrt(Math.floor(16.3));
(h) Give the output of the following code: [2]
String A = “26”, B=”100″;
String D =A+B+”200″;
int x = Integer.parselnt(A);
int y = Integer.parselnt(B);
int d = x+y;
System.out.println(“Result 1 = ”+D);
System.out.prinln(“Result 2 = “+d); ,
(i) Analyze the given program segment and answer the following questions : [2]
for(int i=3;i< =4;i+ +) {
for(int j=2;j<i;j+ +) {
System.out.print(” “); }
System.out.println(“WIN”); }
(i) How many times does the inner loop execute ?
(ii) Write the output of the program segment.
(f) What is the difference between the Scanner class functions next() and nextLine()? [2]
SECTION B (60 Marks)
Attempt 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 descriptions/Mnemonic codes so that the logic of the
program is clearly depicted.
Flow-charts and algorithms are not required.
Question 4: [15]
Write a program in Java to find the perimeter and area of a circle. Accept the radius from the user.
Question 5 [15]
Write a program in Java to find the largest among three numbers x, y, and z using ternary operator.
Accept the values of x, y and z from the user.
Question 6 [15]
Consider First n even numbers starting from zero(0) and calculate sum of all the numbers divisible by
3 from 0 to n. Accept the values of n from the user. Write a program in Java to print the sum.
Question 7 [15]
Write a program in Java to check whether the number is an Armstrong number or not. Armstrong
number is a number that is equal to the sum of cubes of its digits. For example 0, 1, 153, 370, 371
and 407 are the Armstrong numbers.
153 is an Armstrong number.
153 = (1*1*1)+(5*5*5)+(3*3*3)
where:
(1*1*1)=1
(5*5*5)=125
(3*3*3)=27
So:
1+125+27=153
Question 8 [15]
Using switch statement, write a menu driven program for the following :
(i) To find and display the sum of the series given below :
Page 2 of 3
S = x1 -x2 + x2 – x4 + x5 - …….– x20
(where x = 2)
(ii) To display the following series :
1 11 111 1111 11111
For an incorrect option, an appropriate error message should be displayed.
Question 9 [15]
Write a program to accept a number and check and display whether it is a Niven number or not. [15]
(Niven number is that number which is divisible by its sum of digits).
Example:
Consider the number 126.
Sum of its digits is 1+2+6 = 9 and 126 is divisible by 9.
__________________________________________ X ______________________________________
Page 3 of 3