Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Beginning Java and the fly likes inheritance Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "inheritance" Watch "inheritance" New topic


sindura kapur

Joined: Jul 14, 2008
Posts: 22
can a class extend 4 abstract classes
this statement is true or false i think its false but given as true in one site
Joe Matthew
Ranch Hand

Joined: Jun 10, 2008
Posts: 66

Please try it out to find the answer. Its always best to check it out for yourself rather than relying on Books or people.
[ July 25, 2008: Message edited by: Joe Mathew ]

Regards,<br />Joe<br /> <br />"Always program as if the person who will be maintaining your program is a violent psychopath that knows where you live."<br />--Martin Golding
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24199

Well, if the four abstract classes themselves formed an inheritance hierarchy -- i.e., A extends B, B extends C, C extends D, and A-D are all abstract classes, then you could extend A, this making the answer "true". Without more context, it's hard to say what the "right" answer is.

[Jess in Action][AskingGoodQuestions]
Joe Matthew
Ranch Hand

Joined: Jun 10, 2008
Posts: 66
Thats good! Did not think of that!
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46320
But a class can implement 4 interfaces . . . easy!
I agree. Here's the link:
subject: inheritance
It's not a secret anymore!