What is the output of the Java code String a = “hi”; String b = new String(“hi”); System.out.println((a == b) + ” ” + a.equals(b));?
Correct answer C. false true
Subject / 929 questions
Page 15 of Programming multiple-choice questions with answers. Tap an option to check yourself.
Page 15 of 47
Correct answer C. false true
Correct answer D. StringBuffer methods are synchronized, StringBuilder methods are not
Correct answer C. cbXa
Correct answer B. true
Correct answer D. 0
Correct answer B. a.length
Correct answer D. An ArrayIndexOutOfBoundsException is thrown
Correct answer C. true
Correct answer C. An ArrayStoreException is thrown
Correct answer B. Set
Correct answer A. public only
Correct answer B. new A().n
Correct answer C. Static members of its class
Correct answer A. It cannot be subclassed
Correct answer B. It prints 9
Correct answer C. 3
Correct answer D. It must be definitely assigned by the end of every constructor
Correct answer D. A
Correct answer A. Its character sequence cannot change after creation
Correct answer C. 3