Oracle 1Z0-808 Exam question no. 31

Q.– Given:-

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") .msg); 
          }
}

What is the result? 

A) Hello Java SE 8 
     Hello Java SE 8 

B) Compilation fails at the Test class. 

C) Hello java.lang. StringBuilder@<<hashcode1>
     Hello p1.MyString@<<hashcode2>

D) Hello Java SE 8 
     Hello pl.MyString@<<hashcode>>


⧪ please give your answer in a comment section.

Post a Comment

4 Comments