Every Java class extends Object class automatically even if you don't explicitly declare it and the Object class contains a toStrong() method which is used to get a String representing the instance of the Object class. The toString() method of the Object class is implemented to show the reference of object but that is not the actual reference (it is just a text containing information about reference).
However, this method may be overriden by its subclass and this is what what happens to a String class. The toString() method of the String class is overriden to represent the content that the String object holds.
Now, when you use print or println methods on an object, it calls the toString() method of the object and print those values.
In your case, test class has not overriden the toString() method so it prints out whatever value the Object.toString() gives.