954,545 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Inheritance

Hello,
Please tell me in Java we don't have a multiple inheritance? so,in which function we use these inheritance.

Thanks

Simran1
Newbie Poster
3 posts since Dec 2008
Reputation Points: 10
Solved Threads: 0
 

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
Team Colleague
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. :)

chili5
Newbie Poster
21 posts since Dec 2008
Reputation Points: 12
Solved Threads: 2
 

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
 

Hello, Please tell me in Java we don't have a multiple inheritance? so,in which function we use these inheritance.

Thanks


c there is no concept of multiple inheritance in java but some time it seems that there may be a multiple inheritence....

vijendtra
Newbie Poster
1 post since Dec 2008
Reputation Points: 10
Solved Threads: 0
 
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
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You