What is the result?

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

Download Printable PDF. VALID exam to help you PASS.

2 thoughts on “What is the result?

  1. 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

  2. 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.

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.