Sail E0 Webinar

MCQs

Total Questions : 19 | Page 2 of 2 pages
Question 11. String str1 = "Kolkata".replace('k', 'a');In the above statement, the effect on string Kolkata is
  1.    Displays error message
  2.    All characters k are replaced by a.
  3.    All characters a are replaced by k.
  4.    The first occurrence of k is replaced by a.
 Discuss Question
Answer: Option B. -> All characters k are replaced by a.
Question 12. How many objects will be created?String a = new String("Examveda");String b = new String("Examveda");String c = "Examveda";String d = "Examveda";
  1.    4
  2.    None of this
  3.    2
  4.    3
 Discuss Question
Answer: Option D. -> 3
Question 13. 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); } }
  1.    Runtime exception thrown
  2.    Compilation error
  3.    abc
  4.    123
 Discuss Question
Answer: Option C. -> abc
Question 14. How many Constructor String class have?
  1.    7
  2.    None of this
  3.    13
  4.    2
  5.    11
 Discuss Question
Answer: Option C. -> 13
Question 15. The class string belongs to ................. package.
  1.    java.lang
  2.    java.applet
  3.    java.awt
  4.    java.string
 Discuss Question
Answer: Option A. -> java.lang
Question 16. 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)); }}
  1.    false,false
  2.    None of these
  3.    true,false
  4.    false,true
  5.    true,true
 Discuss Question
Answer: Option A. -> false,false
Question 17. What will be output?String S1 = "S1 ="+ "123"+"456";String S2 = "S2 ="+(123+456);
  1.    S1=579,S2=579
  2.    None of This
  3.    S1=123456, S2=579
  4.    S1=123456,S2=123456
 Discuss Question
Answer: Option C. -> S1=123456, S2=579
Question 18. 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. }
  1.    one.two.three.
  2.    None of these
  3.    Compilation fails because of an error at line 3
  4.    An exception is thrown at runtime.
  5.    Compilation fails because of an error at line 5
 Discuss Question
Answer: Option A. -> one.two.three.
Question 19. 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"); } }}
  1.    "1" is printed.
  2.    Compilation fails.
  3.    "2" is printed.
  4.    "3" is printed.
  5.    An exception is thrown at runtime.
 Discuss Question
Answer: Option E. -> An exception is thrown at runtime.

Latest Videos

Latest Test Papers