Strings - Study Mode
[#91] What is the string contained in s after following lines of Java code? StringBuffer s new StringBuffer("Hello")
s.deleteCharAt(0)
Correct Answer
(B) ello
[#92] What will be the output of the following Java program? class output
{
class output
{
public static void main(String args[])
{
char c[]={'A', '1', 'b' ,' ' ,'a' , '0'}
for (int i = 0
i < 5
++i)
{
i++
if(Character.isDigit(c[i]))
System.out.println(c[i]+" is a digit")
if(Character.isWhitespace(c[i]))
System.out.println(c[i]+" is a Whitespace character")
if(Character.isUpperCase(c[i]))
System.out.println(c[i]+" is an Upper case Letter")
if(Character.isLowerCase(c[i]))
System.out.println(c[i]+" is a lower case Letter")
i++
}
}
}
Correct Answer
(C) 1 is a digit a is a lower case Letter
[#93] What will be the output of the following Java code? class output
{
public static void main(String args[])
{
char c[]={'a', '1', 'b' ,' ' ,'A' , '0'}
for (int i = 0
i < 5
++i)
{
if(Character.isDigit(c[i]))
System.out.println(c[i]+" is a digit")
if(Character.isWhitespace(c[i]))
System.out.println(c[i]+" is a Whitespace character")
if(Character.isUpperCase(c[i]))
System.out.println(c[i]+" is an Upper case Letter")
if(Character.isLowerCase(c[i]))
System.out.println(c[i]+" is a lower case Letter")
i=i+3
}
}
}
Correct Answer
(C) a is a lower case Letter A is an upper case Letter
[#94] What will be the output of the following Java program? class output
{
public static void main(String args[])
{
StringBuffer c = new StringBuffer("Hello")
c.delete(0,2)
System.out.println(c)
}
}
Correct Answer
(D) llo
[#95] What will s2 contain after following lines of Java code? StringBuffer s1 = "one"
StringBuffer s2 = s1.append("two")
Correct Answer
(C) onetwo