Home > DeveloperSection > Interviews > What happen if we print an object in java

Posted on    September-22-2015 4:51 AM

 Java Java 
 1 Answer(s)
  893  View(s)
Rate this:

Mayank Tripathi
Mayank Tripathi

Total Post:807

Posted on    September-22-2015 5:14 AM

A a = new A();

It will call the toString() method of that class, if the method is not present in that class, it will look for toSting() method in super class, if its not there, then it will call Object's class toString() method which would give you the memory location (hexadecimal representation) of that object.

Modified On Sep-22-2015 05:22:26 AM

Don't want to miss updates? Please click the below button!

Follow MindStick