Given the definitions of the MyString class and the Test class:
What is the result?
A. Option A
B. Option B
C. Option C
D. Option D
Given the definitions of the MyString class and the Test class:
What is the result?
A. Option A
B. Option B
C. Option C
D. Option D
class MyString{
String msg;
MyString(String msg){
this.msg=msg;
}
}
public class Q94{
public static void main(String[] args) {
System.out.println(“Hello”+ new StringBuilder(“Java Se 8”));
System.out.println(“Hello”+ new MyString(“Java SE 8”));
}
}
result :
HelloJava Se 8
HelloP1.MyString@6cd8737
Answer C:
Applying the println() method on StringBuilder or String objects will print its contents. Unlike other objects in which println() method prints the hascode of the object.