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); } } Compilation error abc Runtime exception thrown 123 TRUE ANSWER : ? YOUR ANSWER : ?
What will be the output?1. public class Test{2. public static void main(String args[]){3. Object myObj = new String[]{"one", "two", "three"};4. {5. for(String s : (String[])myObj) 6. System.out.print(s + ".");7. }8. }9. } None of these one.two.three. Compilation fails because of an error at line 5 An exception is thrown at runtime. Compilation fails because of an error at line 3 TRUE ANSWER : ? YOUR ANSWER : ?
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"); } }} An exception is thrown at runtime. "1" is printed. Compilation fails. "3" is printed. "2" is printed. TRUE ANSWER : ? YOUR ANSWER : ?
What could be output of the following fragment of code?public class Test{ public static void main(String args[]){ String x = "hellow";int y = 9;System.out.println(x += y); } } None of these 9hellow Throws an exception as string and int are not compatible for addition hellow9 Compilation error TRUE ANSWER : ? YOUR ANSWER : ?
Determine output:public class Test{ public static void main(String args[]){ String s1 = "SITHA";String s2 = "RAMA";System.out.println(s1.charAt(0) > s2.charAt(0)); }} false Compilation error true Throws Exception 0 TRUE ANSWER : ? YOUR ANSWER : ?
The output of the following fraction of code ispublic class Test{ public static void main(String args[]){ String s1 = new String("Hello");String s2 = new String("Hellow");System.out.println(s1 = s2);}} Compilation error Hello Throws an exception Hellow None of these TRUE ANSWER : ? YOUR ANSWER : ?
toString() method is defined in java.lang.util None of these java.lang.Object java.lang.String TRUE ANSWER : ? YOUR ANSWER : ?
The class string belongs to ................. package. java.string java.applet java.awt java.lang TRUE ANSWER : ? YOUR ANSWER : ?
What is the output of the following println statement?String str1 = "Hellow";System.out.println(str1.indexOf('t')); -1 false true 1 0 TRUE ANSWER : ? YOUR ANSWER : ?
String str1 = "Kolkata".replace('k', 'a');In the above statement, the effect on string Kolkata is Displays error message All characters k are replaced by a. All characters a are replaced by k. The first occurrence of k is replaced by a. TRUE ANSWER : ? YOUR ANSWER : ?