• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

inheritance

 
atif toor
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
suppose we have three classes A,B,C. A is parent class of B and C. B is parent class of C.Can class C finish inheritance of class A and class B OR Can class A finish inheritance of class B and class C. If answer is yes how?
Thankz in advance
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"finish inheritance"???
A is a super class of B which is a super class of C.
A
|
B
|
C
All B's inherit from A.
When you create a C it inherits from B, including the stuff from A.
 
atif toor
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A
|
B
|
C
Actually my question is "Can an object of class A destroy the inheritance of class B and class C.
Class C extands class B (I want to finish this relation ship through any object of other class)
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So you mean can you stop being a subclass or a superclass suddenly?
No, at least not dynamically - as you are executing.
Class A can PREVENT subclassing by being final.
like "public final class Math"
And if it was not final, and there is a subclass, if you stop and make the super class "final" and recompile, and then try to run the subclass - you get a
java.lang.VerifyError: Class B is a subclass of final class A
 
atif toor
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thankz Cindy
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic