What is the difference between?
Object o=new Person();
and Person p=new Person();
posted 1 year ago
In one case you are declaring it as Object; you can only use methods in the Object class, and you can replace it with a different type.
In the other case you are declaring it as Person and you can use any methods of the Person class too, but you can only replace the reference with another reference to something which is a Person object.