Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

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

user-image
Question added by Deleted user
Date Posted: 2014/03/20
Maria Thomas
by 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
by 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