You are on page 1of 3

PRELIMINARY EXAMINATIONS – 2015

COMPUTER APPLICATIONS
Grade: 10 Time allowed: 2 Hours
Date: 19 / 01/ ‘15 Maximum marks: 100

Answer ALL questions in Section A(compulsory) and FOUR questions from Section B
All working, including rough work must be on the same sheet as the rest of the answer
The intended marks for questions are given in [] brackets

SECTION A
Answer All Questions
While answering this Section, indicate briefly your working and reasoning.
Question 1
a) Name any two statements in Java that facilitates transfer of control to another part
of a program. Where do they transfer the control to? [2]
b) State the total size in bytes, of the arrays a[5] of char data type and p[5] of double
data type. [2]
c) Differentiate call by value and call by reference. [2]
d) Give the significance of “default” in a switch case construct. State one limitation of
switch construct over nested if structure in Java. [2]
e) List two unary operators in Java and the type of operators each one belongs to. [2]

Question 2
a) State two differences between equals( ) and compareTo( ) methods. [2]
b) What is Function overloading?. Which feature of OOP does it implement? [2]
c) Give any two methods of the Character library class with the correct syntax
of using it [2]
d) Explain the purpose of the keyword “final” if used in a Java program. [2]
e) Give the packages of Scanner and Printer classes of Java. How do you input
a String using scanner class [2]

Question 3
a) Give the output of each of the code segments [2 + 2]
(i) int a = 2, y = 19, z;
z = ++a * ++y + a;
System.out.println( “ z = “ + z );

(ii) int a = 9, b = 12, c = 10, k;


k = ++a * b-- / c++ + a++;
System.out.println( k + “ “ + a );
b) Write a Java statement to create an object named 'jfs' of a class 'Computer' that
invokes a parameterized constructor with two integer type arguments. [2]

THIS PAPER CONSISTS OF THREE PRINTED SIDES

Page 1 of 3
c) Give the output of the following program segment. Show the dry run. [3]
public static void main()
{
int r = 0, d = 23;
String s = new String( );
while( d != 0 )
{
r = d % 2;
s = r + s;
d /= 2;
}
System.out.println(s);
}

d) What is the output of the following code snippet? [3]


String s1 = new String ( "Batman and Robin" );
String s2 = new String ( "The Cat will not move the cheese" );
String s3=new String( ); String s4=new String( );
s3 = s2.substring ( s2.lastIndexOf( 'C' ), s2.lastIndexOf ( 'C' ) + 3 );
s4 = s3.concat( "wo" ). concat ( s1.substring ( 3 ) );
System.out.println ( s4 );
e) Write a statement for each of the following. [3]
(i) Store a number 45.56 as a String.
(ii) To display the Unicode (ASCII) equivalent of an character x.
(iii) To declare a float array that can store the temperature readings for the month of January.
f) If int A[ ] = { 9, 8, 0, 4, 5, 6, 6, 8, 1, 5 }, What will be the values of 'm' and 'n' after
the following code is executed? [2]
m = Math.max ( Math.pow ( A[1], A[2] ) , Math.sqrt ( A[3] ) );
n = Math.pow ( Math.min ( A[1], A[7] ), ++A[2] );

g) Write the output for the following code segment: [3]


for ( int i = 0; i < 2; i++ )
{ for ( int j = 2; j > 0; j-- )
{ if ( i = = j )
break;
System.out.println ( i + “ ” + j );
}
}

SECTION B
Answer any FOUR questions
Each program should be written in such a way that it clearly depicts logic of program
and supported by sufficient comments and declaration of variables used.

Question 4 [15]
Write a program that generates the prime-palindrome numbers between the range m and n (both inclusive),
where m and n are positive integers and m < n. Prime-palindrome numbers are those that are prime numbers
and also palindromes. Examples : 101, 131…..

Page 2 of 3
Question 5 [15]
Define a class Student having the following description:
Data members : name, age, m1, m2, m3 ( marks in 3 subjects ), max, avg
Member functions:
A parameterized constructor to initialize data members
To accept the details of a student
To compute the average and maximum of three subject marks
To display the details of the student.
Write a main method to create an object of the class and call the methods.

Question 6 [15]
Write a program to input the marks of N students in a one dimensional array and print
the mode and frequency of mode. Mode is the most frequently occurring mark and
frequency of mode is the number of times that frequently occurring marks i.e. mode repeats.
If more than one mark appears of same frequency, the higher of the two marks is the mode.

Question 7 [15]
Store the 10 users’ names and their respective passwords in two different String arrays.
Write a program that accepts one user name and password and performs the following:
The program should print “Welcome <user name>” if the user name exists and the password matches.
If the user name does not exist, the program should print the message “User does not exists” and exit the
program.
If the user name is found, but the password does not match, the program should print the message “Invalid
password” and exit the program.

Question 8 [15]
Create a class to overload a function reverse( ) that reverses a string or an integer or a floating point number
( 357.63 to be reversed as 753.36) and returns the same.

Question 9 [15]
Write a program to input a string and print out the text with the uppercase and lowercase letters reversed,
but all other characters should remain the same as before.
Example : Input : WelComE TO School
Output: wELcOMe to sCHOOL

Input : james BOND 007


Output : JAMES bond 007

***********************

Page 3 of 3

You might also like