Page 385 - Computer science 868 Class 12
P. 385
{
if(i%2!=0)
{
newstr +=Character.toLowerCase(str.charAt(i));
}
else
newstr+= str.charAt(i);
}
i++;
}
System.out.println(newstr);
}
Ans. InDIANaRmY
13. String a = "Computer";
String b = "Science";
What do the following function return?
System.out.println(b.charAt(5) + a.substring(5));
Ans. cter
14. What will be the result of the following?
public static void main(String []args)
{
String s1="James", s2="Gosling";
System.out.println(s1.substring(1,4));
System.out.println(s1.equalsIgnoreCase("james"));
}
Ans. ame
true
Unsolved Questions
A. Tick ( ) the correct option:
1. Output of "Computer".substring(1,6); is
a. comp b. Comp
c. Computer d. None of these
2. String s= "7";
int t =Integer.parseInt(s);
t=t+1000;
System.out.println(t);
a. 10007 b. 1000
c. 1007 d. None of these
3. Find the output of the following program snippet:
char ch = 'y';
char chr = Character.toUpperCase(ch);
int p = (int) chr;
System.out.println(chr + "\t" + p);
a. Y 89 b. Y 90
c. A 89 d. All of these
4. What will be the result of the following?
String a="10", b="20";
383
Strings 383

