Two Laptop Bag
The moose likes Beginning Java and the fly likes extend class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "extend class" Watch "extend class" New topic

extend class

Jello Yao

Joined: Jan 05, 2003
Posts: 13
Can a subclass extend more than one class during declaration? i.e. class Sheep extends Cattle, Animal. Thanks!
Ilja Preuss

Joined: Jul 11, 2001
Posts: 14112
No, it can only extend one class and implement as many interfaces as you want.

The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Divya Venkatesh

Joined: Nov 05, 2002
Posts: 28
Java does not allow multiple inheritance.You may extend Just one class and implement as many interfaces as you need just providing functions for the abstract methods.
Hope this helps.

bhatti mansha

Joined: Jan 03, 2003
Posts: 7
no , java can not aloud to make multiple superclasses
but a superclass have a lot of sub classes
means eg
class a{
class b extends a{
class c extends a{
in it "a" is a super class and "b" is sub class who extend him but "c" also extends "a" so "a" is also superclass of "C".
it is possible;
but a subclass can not create a multiple
class a{
class b extends a{
class c extends a,b {// error
but interface u can extends more then 2 interface
interface a {
interface b{
class C implement a,b{
it is possible
ok i hope u r clear more
if i can write some wrong plz clear me
Robbie shi

Joined: Jan 05, 2003
Posts: 28
in java one class can only have a direct
----------------------------- IDE tool : JawaBeginer
2.Java Jar tool : JavaJar
boyet silverio
Ranch Hand

Joined: Aug 28, 2002
Posts: 173
though different, its also good learning if you explore classes in relation to interfaces. A class could implement many of them e.g. class TClass implements Interface1, Interface2{....
I agree. Here's the link:
subject: extend class
It's not a secret anymore!