In#eritance is one o' t#e t #e %ost po)er'ul 'eature o' object oriented pro(ra%%in(*
In#eritance is t#e process o' creatin( ne) classes+ called derived classes or Sub Classes or c#ild classes 'ro% e!istin( classes called c alled base classes or Super Classes or parent classes*
,#e derived class in#erits all t#e capabilities o' t#e base class but can add e%bellis#%ents and re'ine%ents o' its o)n* ,#e base class is unc#an(ed b t#is t #is process* Grand Parent Class Parent Class C#ild Class
Sin(le In#eritance supported b ABAP Objects
Parent Class
Parent Class
C#ild Class Multiple In#eritance not supported b ABAP Objects
IBM Global Business Services
Inheritance : Concept !Contd"# &oot node
n o i t a ( i & a r e n e '
$%per C&ass
,#e relations#ip bet)een t#e base classes and t#e derived classes can be represented in an In#eritance tree* #ere base classes o' eac# derived class can be retraced alon( an uni.ue pat# to a sin(le root node o' t#e tree*
A Super Super Class is a Generali/ation o' its Sub Classes and on t#e ot#er #and a Sub Class is a Speciali/ation o' its Super Class*
+ede>inition is )#en t#e i%ple%entation o' an in#erited instance %et#od is c#an(ed 'or t#e Sub Class )it#out c#an(in( its si(nature* $tatic 9ethods cant be rede>ined * ,#e para%eters re%ain sa%e in t#e derived class as it )as in base class* In t#e rede'ined %et#od use t#e t #e $8P5+ pseudo re'erence to access t#e ori(inal %et#od o' t#e base class*
As all public and protected co%ponents+ Sub Class in#erits t#e constructor %et#od i' it is present in t#e in#eritance tree*
I' an object o' Sub Class is created at t#is ti%e t#e in#erited instance attributes and private attributes o' t#e Super Classes %ust also be initiali/ed*
As t#e private attributes o' t#e Super Class is not visible to Sub Class+ Sub Class cannot 'ull initiali/e its Super Class* ,#ere'ore to ensure co%plete initiali/ation o' Sub Class and its Super Classes+ constructor is called*
#et#er e!plicit e!plicit call is re.uired 'or t#e instance constructor o' t#e Super Class or not + )#en )e instantiate an object o' Sub Class is depends on t#e 'ollo)in( conditions4
,#e rede'inition o' static constructor )ors si%ilarl to instance constructor*
#en an static constructor is rede'ined t#en &898$I5I,IO5 addition is not re.uired*
5o para%eter inter'ace is possible 'or ' or static constructor 1 )it# or )it#out in#eritance3
,#e runti%e environ%ent auto%aticall ensures t#at t#e static constructors are called in t#e ri(#t order+ so it is not re.uired to call t#e static constructor o' t#e Super Class e!plicitl*
C&ass C2 Inheritin >ro9 C1 P%b: a1< a2ic co%ponents o' instances need to be addressed and t#eir re'erences are ept in variables t#at are tped on t#e Super Class*
&e'erence variables declared )it# static re'erence to a Super Class can dna%icall point to an object o' a Sub Class o' t#is Super Class and access t#e co%ponents no)n to t#e Super Class* Met#ods in#erited 'ro% Super Class %a be rede'ined in one or %ore o' t#e Sub Classes* ,#is is t#e basis o' pol%orp#is% pol%orp#is% usin( in#eritance*
Pol%orp#is% #ere %eans usin( t#e sa%e na%e via sa%e inter'ace to uni'or%l address di''erentl i%ple%ented %et#ods+ belon(in( to di''erent objects o' di''erent classes in t#e in#eritance tree*
Thank you for interesting in our services. We are a non-profit group that run this website to share documents. We need your help to maintenance this website.