Page 445 - CA_Blue( J )_Class10
P. 445
Previous Years' Questions
SECTION A
1. Write the output: [2017]
char ch = 'F';
int m = ch;
m = m + 5;
System.out.println(m + " " + ch);
Ans. 75 F
2. Write the output for the following: [2017]
String s = "Today is Test";
System.out.println(s.indexOf('T'));
System.out.println(s.substring(0, 7) + " " + "Holiday");
Ans. 0
Today i Holiday
3. State the output when the following program segment is executed: [2015]
String a = "Smartphone", b = "Graphic Art";
String h = a.substring(2, 5);
String k = b.substring(8).toUpperCase();
System.out.println(h);
System.out.println(k.equalsIgnoreCase(h));
Ans. art
true
4. Write the output of the following program code: [2015]
char ch;
int x = 97;
do{
ch = (char)x;
System.out.print(ch + " ");
if(x % 10 == 0)
break;
++x;
}while(x <= 100);
Ans. a b c d
5. State the output of the following program segment:
String str1 = "great"; String str2 = "minds";
System.out.println(str1.substring(0, 2).concat(str2.substring(1)));
System.out.println(("WH" + (str1.substring(2).toUpperCase()))); [2014]
Ans. grinds
WHEAT
6. What is the data type returned by the library functions:
(i) compareTo() (ii) equals() [2014]
Ans. (i) int (ii) boolean
7. State the value of characteristic and mantissa when the following code is executed:
String s = "4.3756";
int n = s.indexOf('.');
int characteristic = Integer.parseInt(s.substring(0, n));
int mantissa = Integer.valueOf(s.substring(n + 1));
Ans. characteristic = 4 mantissa = 3756
443
String Handling 443

