mercredi 6 mai 2015

results of one of the ways to declare a new object with a parent class and a subclass

I have a Java-related question.

I have a public class Parent and its subclass public class Child extends Parent.

If I were to declare a new object as

Parent p = new Child();

would p be able to use the methods of Child and Parent? Or only Parent?

Additionally, what would be the difference in declaring p as

Child p = new Child(); 

if Child extends parent already?

Aucun commentaire:

Enregistrer un commentaire