nerdexam
Oracle

1Z0-808 · Question #13

Given the definitions of the MyString class and the Test class: MyString.java: package p1; class MyString { String msg; MyString(String msg) { this.msg = msg; } } Test.java: package p1; public class T

Sign in or unlock 1Z0-808 to reveal the answer and full explanation for question #13. The question stem and answer options stay visible for context.

Using Operators and Decision Constructs

Question

Given the definitions of the MyString class and the Test class: MyString.java: package p1; class MyString { String msg; MyString(String msg) { this.msg = msg; } } Test.java: package p1; public class Test { public static void main(String[] args) { System.out.println("Hello " + new StringBuilder("Java SE 8")); System.out.println("Hello " + new MyString("Java SE 8")); } } What is the result?

Options

  • AHello Java SE 8 Hello Java SE 8
  • BHello java.lang.StringBuilder@<hashcode1>> Hello p1.MyString@<hashcode2>>
  • CHello Java SE 8 Hello p1.MyString@<hashcode>>
  • DCompilation fails at the Test class.

Unlock 1Z0-808 to see the answer

You've previewed enough free 1Z0-808 questions. Unlock 1Z0-808 for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.

Topics

#String concatenation#toString() method#StringBuilder#Object.toString()
Full 1Z0-808 Practice