READ Free Dumps For Oracle- 1z0-803
Question ID 21935 | Given:
String message1 = "Wham bam!";
String message2 = new String("Wham bam!");
if (message1 == message2)
System.out.println("They match");
if (message1.equals(message2))
System.out.println("They really match");
What is the result?
|
Option A | They match
They really match
|
Option B | They really match
|
Option C | They match
|
Option D | Nothing Prints
|
Option E | They really match
They really match
|
Correct Answer | B |
Explanation Explanation: The strings are not the same objects so the == comparison fails. See note #1 below. As the value of the strings are the same equals is true. The equals method compares values for equality. Note: #1 == Compares references, not values. The use of == with object references is generally limited to the following: Comparing to see if a reference is null. Comparing two enum values. This works because there is only one object for each enum constant. You want to know if two references are to the same object.
Question ID 21936 | Given:
public class Speak { /* Line 1 */
public static void main(String[] args) { /* Line 2 */
Speak speakIT = new Tell(); /* Line 3 */
Tell tellIt = new Tell(); /* Line 4 */
speakIT.tellItLikeItIs(); /* Line 5 */
(Truth)speakIt.tellItLikeItIs(); /* Line 6 */
((Truth)speakIt).tellItLikeItIs(); /* Line 7 */
tellIt.tellItLikeItIs(); /* Line 8 */
(Truth)tellIt.tellItLikeItIs(); /* Line 9 */
((Truth)tellIt).tellItLikeItIs(); /* Line 10 */
}}
class Tell extends Speak implements Truth {
public void tellItLikeItIs() {
System.out.println("Right on!");
}} interface Truth {
public void tellItLikeItIs()};
Which three lines will compile and output "right on!"?
|
Option A | Line 5
|
Option B | Line 6
|
Option C | Line 7
|
Option D | Line 8
|
Option E | Line 9
|
Option F | Line 10
|
Correct Answer | A,D,F |
Explanation