I know java doesnot support multiple inheritence.lets say my class A extends B.Now my class A is extending class B as well as Object Class .how this happens?Why class A gets compiled?
sarath.koiloth
0
Light Poster
Recommended Answers
Jump to PostYou can inherit from a single parent downwards as far as you want...
A extends Object; B extends A; C extends B; etc
Thus, by implication, C extends B, A, and Object.
What you can't do is this:
E extends F,G
ie. extend from two parents at the same level. …
Jump to PostThe language was setup so that you can't have multiple inheritance. If you want multiple inheritance, you have to use interfaces. By using keyword "implements" in the class heading.
extends - for classes
implements - for interfaces
Jump to PostYeah interfaces are somewhat similar - if your class "implements" the interface, it forces you to include those methods that are defined in the interface itself.
All 11 Replies
JamesCherrill
4,667
Most Valuable Poster
Team Colleague
Featured Poster
jmaat7
0
Light Poster
BestJewSinceJC
700
Posting Maven
sarath.koiloth
0
Light Poster
JamesCherrill
4,667
Most Valuable Poster
Team Colleague
Featured Poster
sarath.koiloth
0
Light Poster
JamesCherrill
4,667
Most Valuable Poster
Team Colleague
Featured Poster
sarath.koiloth
0
Light Poster
JamesCherrill
4,667
Most Valuable Poster
Team Colleague
Featured Poster
sarath.koiloth
0
Light Poster
JamesCherrill
4,667
Most Valuable Poster
Team Colleague
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.