File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "extend class" Watch "extend class" New topic
Author

extend class

Jello Yao
Greenhorn

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
author
Sheriff

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
Greenhorn

Joined: Nov 05, 2002
Posts: 28
No,
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.


Divya
bhatti mansha
Greenhorn

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
superclasses
eg
class a{
}
class b extends a{
}
class c extends a,b {// error
}
but interface u can extends more then 2 interface
e.g
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
thanx
Faheem
Robbie shi
Greenhorn

Joined: Jan 05, 2003
Posts: 28
in java one class can only have a direct
superclass
--
Robbies
-----------------------------
1.java IDE tool : JawaBeginer
2.Java Jar tool : JavaJar
http://www.pivotonic.com
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: http://aspose.com/file-tools
 
subject: extend class
 
Similar Threads
Interface
how makeChild classes as Non Serializable if parent class is Serializable in java ?
Blank JOptionPane RMI
Instance blocks.
Class declarations