All the classes defined are subclasses by default.
Object is a superclass of every class.
The inheritance happens automatically.
Your classes will inherit members from the class Object.
Method
Purpose
toString()
returns a string describing the current object
equals()
compares two objects
getClass()
returns a Class that identifies the class of the current object.
hashCode()
calculates a hashcode for an object
notify()
wakes up a thread associated with the current object.
notifyAll()
wakes up all threads associated with the current object.
wait()
causes a thread to wait
class Dog{ public Dog(String aType){
}
} public class MainClass{ public static void main(String[] a){
Dog d = new Dog("a"); Class objectType = d.getClass();
System.out.println(objectType.getName());
}
}