Question 1 of 25
Hints left: 3
Q1
Which of these is an incorrect statement?
Q2
What will be the output of the following Java program? class output { public static void main(String args[]) { String s1 = "Hello World"; String s2 = s1.substring(0 , 4); System.out.println(s2); } }
Q3
What is the value returned by function compareTo() if the invoking string is less than the string compared?
Q4
Which of these method of class String is used to extract a single character from a String object?
Q5
What will be the output of the following Java program? class output { public static void main(String args[]) { String s1 = "one"; String s2 = s1 + " two"; System.out.println(s2); } }
Q6
Which of these method of class String is used to extract more than one character at a time a String object?
Q7
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++; } } }
Q8
Which of these method of class StringBuffer is used to find the length of current character sequence?
Q9
What will be the output of the following Java program? class String_demo { public static void main(String args[]) { char chars[] = {'a', 'b', 'c'}; String s = new String(chars); System.out.println(s); } }
Q10
Which of these methods of class String is used to check whether a given object starts with a particular string literal?
Q11
Which of this method of class StringBuffer is used to get the length of the sequence of characters?
Q12
Which of these constructors is used to create an empty String object?
Q13
Which of this method of class String is used to obtain a length of String object?
Q14
What will be the output of the following Java code? class output { public static void main(String args[]) { String c = "Hello i love java"; int start = 2; int end = 9; char s[]=new char[end-start]; c.getChars(start,end,s,0); System.out.println(s); } }
Q15
What will be the output of the following Java code? class output { public static void main(String args[]) { char ch; ch = "hello".charAt(1); System.out.println(ch); } }
Q16
Which of these class is superclass of String and StringBuffer class?
Q17
Which of this method of class StringBuffer is used to reverse sequence of characters?
Q18
What is the string contained in s after following lines of Java code? StringBuffer s new StringBuffer("Hello"); s.deleteCharAt(0);
Q19
In the following Java code, which code fragment should be inserted at line 3 so that the output will be: "123abc 123abc"? 1. StringBuilder sb1 = new StringBuilder("123"); 2. String s1 = "123"; 3. // insert code here 4. System.out.println(sb1 + " " + s1);
Q20
What will be the output of the following Java program? class output { public static void main(String args[]) { String s = "Hello World"; int i = s.indexOf('o'); int j = s.lastIndexOf('l'); System.out.print(i + " " + j); } }
Q21
What will be the output of the following Java program? class String_demo { public static void main(String args[]) { int ascii[] = { 65, 66, 67, 68}; String s = new String(ascii, 1, 3); System.out.println(s); } }
Q22
What will s2 contain after following lines of Java code? StringBuffer s1 = "one"; StringBuffer s2 = s1.append("two")
Q23
Which of this method of class String is used to extract a substring from a String object?
Q24
Which of this method of class StringBuffer is used to concatenate the string representation to the end of invoking string?
Q25
What is the value returned by function compareTo() if the invoking string is greater than the string compared?