Question 1 of 25
Hints left: 3
Q1
The class string belongs to ................. package.
Q2
How many objects will be created? String a = new String("Examveda"); String b = new String("Examveda"); String c = "Examveda"; String d = "Examveda";
Q3
Determine output: public class Test{ public static void main(String args[]){ String str = null; if(str.length() == 0){ System.out.print("1"); } else if(str == null){ System.out.print("2"); } else{ System.out.print("3"); } } }
Q4
Which of the following are incorrect form of StringBuffer class constructor?
Q5
What will be the output of the following Java code? class output { public static void main(String args[]) { String s1 = "Hello i love java"; String s2 = new String(s1); System.out.println((s1 == s2) + " " + s1.equals(s2)); } }
Q6
What will be the output? public class Test{ public static void main(String args[]){ Object myObj = new String[]{"one", "two", "three"}; { for(String s : (String[])myObj) System.out.print(s + "."); } } }
Q7
What will be the output of the following Java code? class output { public static void main(String args[]) { StringBuffer sb=new StringBuffer("Hello"); sb.replace(1,3,"Java"); System.out.println(sb); } }
Q8
Which of these class is used to create an object whose character sequence is mutable?
Q9
What is the output of the following println statement? String str1 = "Hellow"; System.out.println(str1.indexOf('t'));
Q10
Which of these data type value is returned by equals() method of String class?
Q11
What will be the output of the following program? public class Test{ public static void main(String args[]){ String str1 = "one"; String str2 = "two"; System.out.println(str1.concat(str2)); } }
Q12
Which of these methods can be used to convert all characters in a String into a character array?
Q13
Which of these method of class String is used to remove leading and trailing whitespaces?
Q14
What will be the output of the following Java code? class output { public static void main(String args[]) { StringBuffer s1 = new StringBuffer("Hello"); s1.insert(1,"Java"); System.out.println(s1); } }
Q15
What will be output? String S1 = "S1 ="+ "123"+"456"; String S2 = "S2 ="+(123+456);
Q16
Which of the following statement is correct?
Q17
What will be the output of the following Java program? class output { public static void main(String args[]) { String a = "hello i love java"; System.out.println(a.indexOf('e')+" "+a.indexOf('a')+" "+a.lastIndexOf('l')+" "+a.lastIndexOf('v')); } }
Q18
What will be the output of the following Java code? class output { public static void main(String args[]) { String c = "Hello i love java"; boolean var; var = c.startsWith("hello"); System.out.println(var); } }
Q19
What will be the output of the following Java program? class output { public static void main(String args[]) { String c = " Hello World "; String s = c.trim(); System.out.println("\"+s+""""\""""""); } }"""
Q20
String str1 = "Kolkata".replace('k', 'a'); In the above statement, the effect on string Kolkata is
Q21
What will be the output of the following Java program? class output { public static void main(String args[]) { String s1 = "Hello"; String s2 = s1.replace('l','w'); System.out.println(s2); } }
Q22
What will be the output? public class Test{ public static void main (String[] args){ String test = "a1b2c3"; String[] tokens = test.split("\\d"); for(String s: tokens) System.out.print(s); } }
Q23
How many Constructor String class have?
Q24
Which of these methods is used to compare a specific region inside a string with another specific region in another string?
Q25
What will be the output of the following program code? public class Test{ public static void main(String args[]){ String s = "what"; StringBuffer sb = new StringBuffer("what"); System.out.print(sb.equals(s)+","+s.equals(sb)); } }