Communiquez avec les autres et partagez vos connaissances professionnelles

Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.

Suivre

Why to define reference variable of abstract class if we connot create object in java?

user-image
Question ajoutée par Utilisateur supprimé
Date de publication: 2014/03/20
Maria Thomas
par Maria Thomas , Tech Lead , J P Morgan Chase

A reference variable of an abstract class is created for the same reason as creating for an interface. It is to allow the downcasting of the object to any of the sub classes that inherit the abstract class as the case might be. It makes use of the concept of polymorphism by which object is created for the superclass and at run time is made to refer to either of the sub classes as requirement.

Mohamed Hassan
par Mohamed Hassan , Senior Application and Integration Developer , IBM

the variable should be define as

public static final

this way all you nedd is to call like that

ClassName.variablName

 

More Questions Like This