What will happen when the following code is compiled and executed?

00: package test;
01: public class Test {
02:     public static void main(String [] args) {
03:          Test test = new Test();
04:          System.out.println(test.toString());
05:     }
06: }
Explanation
All objects in Java are inherited from the Object class. Since a Test class does not override a toString() method, it will use its Object class implementation, which returns a string representation of the object as follows: class name (with a full package name) + @ symbol + hexadecimal unsigned value of object's hash code
Java
Java Quiz
Start Quiz

or Read more about Java Quiz

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback