System.out is an object of type java.io.PrintStream. The println(Object) method of class PrintStream prints whatever returns from the invocation to String.valueOf(Object). The latter's code is:
return (obj == null) ? "null" : obj.toString();
that is, if the object is null, the
string literal "null" will be printed, otherwise the toString() method is invoked on the object and the result is returned.
In your case, "A" gets printed because toString() is invoked on a1[0].
The java.lang.Object class implements a basic version of the toString method whose code looks as follows:
return getClass().getName() + "@" + Integer.toHexString(hashCode());
that is the class name, followed by "@", followed by the hashcode in a hexadecimal string.
When you renamed toString() to toString1(), the basic toString() version has been invoked, yielding the result you mentioned.