Hello,
Please tell me in Java we don't have a multiple inheritance? so,in which function we use these inheritance.
Thanks
You say:
> we don't have a multiple inheritance
but then you ask:>in which function we use these inheritance
The only thing I can say is that java doesn't have multipleclass inheritance, but multiple Interface implementation.
If that doesn't cover you, ask a better question
javaAddict
Nearly a Senior Poster
3,329 posts since Dec 2007
Reputation Points: 1,014
Solved Threads: 448
What do you mean?
There isn't multiple inheritance in Java. It's a single inheritance only language. :)
That's what javaAddict said, Java does not have multiple class inheritance, you can only only extend (is-A) one class. However you can implement (has-A) any amount of interfaces you want.
jasimp
Senior Poster
3,623 posts since Aug 2007
Reputation Points: 533
Solved Threads: 53
That's what javaAddict said, Java does not have multiple class inheritance, you can only only extend (is-A) one class. However you can implement (has-A) any amount of interfaces you want.
Hi Sriran1 ,
what jasimp said is correct expect that implementing a interface is *NOT* mean "Has-A" relationship.
Has-A relationship is what when an Class has other Class's object in it's attribute
Implementing a interface is also means "Is-A" relationship
e.g
//for Is-A
class Mammal {
}
class Dog extends Mammal { }
//for Has-A
class Tail { }
class Dog extends Mammal { // Dog IS-A mammal
Tail tail ; // and Has-A Tail
}
parthiban
Junior Poster in Training
80 posts since Sep 2006
Reputation Points: 10
Solved Threads: 6