ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

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

user-image
تم إضافة السؤال من قبل مستخدم محذوف‎
تاريخ النشر: 2014/03/20
Maria Thomas
من قبل 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
من قبل 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

 

المزيد من الأسئلة المماثلة