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. } Compilation fails because of an error at line 5 None of these Compilation fails because of an error at line 3 one.two.three. An exception is thrown at runtime. TRUE ANSWER : ? YOUR ANSWER : ?
What will be output?String S1 = "S1 ="+ "123"+"456";String S2 = "S2 ="+(123+456); S1=123456,S2=123456 None of This S1=123456, S2=579 S1=579,S2=579 TRUE ANSWER : ? YOUR ANSWER : ?
toString() method is defined in None of these java.lang.util java.lang.String java.lang.Object TRUE ANSWER : ? YOUR ANSWER : ?
What will be the output?String str1 = "abcde";System.out.println(str1.substring(1, 3)); bcd None of these abc abcd bc TRUE ANSWER : ? YOUR ANSWER : ?
The class string belongs to ................. package. java.string java.awt java.lang java.applet TRUE ANSWER : ? YOUR ANSWER : ?
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)); }} None of these false,false false,true true,false true,true TRUE ANSWER : ? YOUR ANSWER : ?
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); } } 123 Compilation error abc Runtime exception thrown TRUE ANSWER : ? YOUR ANSWER : ?
What will be the output of the following program?public class Test{ public static void main(String args[]){String s1 = "java";String s2 = "java";System.out.println(s1.equals(s2));System.out.println(s1 == s2); }} true true false false true false false true 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 a are replaced by k. All characters k are replaced by a. The first occurrence of k is replaced by a. 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"); } }} "3" is printed. An exception is thrown at runtime. "2" is printed. Compilation fails. "1" is printed. TRUE ANSWER : ? YOUR ANSWER : ?