X – ICSE [2010]
General Instructions
Question 1 [5 * 2 = 10]
Question 2 [5 * 2 = 10]
a) Write the equivalent switch case statement for the following decision making
situation.
If(x==’1’ || x==’3’)
a=1;
if(x==’5’) a=2;
if(x==’7’) a=3
else a=10;
i. assume num as -1
ii. assume num as 6
c) Differentiate between if and switch statements.
d) Explain the meaning of break and continue statements.
e) Explain, with the help of an example, the purpose of default in a switch statement.
Question 3 [20]
i. System.out.prinln(x+y);
ii. System.out.println(x.length());
iii. System.out.println(x.charAt(3));
iv. System.out.println(x.equals(y));
i. math.ciel(-28.25)
ii. math.rint(38.96)
iii. Math.floor ( 144.99)
iv. Math.abs ( 3489.45)
v. Math.max ( Math.min (15, 25), 5)
vi. ( int ) (“scholar”.charAt(2))
vii. “TuTOrIAl”.indexOf(‘l’)
viii. “MISSISSIPPI”.lastindexOf(‘S’)
ix. “kumarvivek”.substring( 3, 4)
x. Math.sqrt(100);
1) Write a program to input any given string to calculate the total number of
characters and vowels present in the string and also reverse the string: - [15]
Example : INPUT
Enter String : SNOWY
OUTPUT
Total number of characters : 05
Number of Vowels : 01
Reverse string : YWONS
2) Write a program to print the sum of negative numbers, sum of positive even
numbers and sum of positive odd numbers from a list of numbers(N) entered by the
user. The list terminates when the user enters a zero. [15]
3) Write an application that inputs a line of text and output the text twice – once in all
upper case and once in all lower case letters.
5) A boy enters a string in which he repeats few alphabets accidentally. Now write a
program by taking that string as input to remove repeated alphabets from the string.
Then display both original and newly formed string on the screen.(15)