aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Abstract class and interface. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Abstract class and interface." Watch "Abstract class and interface." New topic
Author

Abstract class and interface.

SHINU .R SHINU .R
Greenhorn

Joined: Sep 02, 2005
Posts: 12
ANY BODY CAN TELL WHAT IS THE EXACT DIFFERENCE BETWEEN ABSTRACT CLASS AND INTERFACE???
wHERE THESE ARE USE??WHERE NOT USED
[ September 02, 2005: Message edited by: Barry Gaunt ]
Swapna James
Ranch Hand

Joined: Jul 26, 2005
Posts: 56
Hi,

Abstract classes and interfaces cannot be instantiated

Abstract class can contain non abstract methods while interface cannot contain any non abstract methods

Interface should contain all public members while abstract classes can have public, protected, default and private members.

These are the major differences.

Swapna


SCJP 1.4
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Shinu R, please read our JavaRanch Naming Policy and change your displayed name to comply. We need a displayed name in the format <first name><space><family name>, preferably your real name.

And please do not post in capital letters, there is no need to draw attention to yourself in this impolite way.
Thanks,
-Barry

(NR)
[ September 02, 2005: Message edited by: Barry Gaunt ]

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
kailash mehra
Greenhorn

Joined: Sep 02, 2005
Posts: 2
interface cann't be protected or private but it can be default or public .
abstract class can have all access modifiers.
Megs Maquito
Ranch Hand

Joined: May 18, 2005
Posts: 84
Abstract classes are usually the Parent classes Ex. class Animal. Then you probably would have a subclass Canine Extends Animal. Then after that you may have a class Dog Extends Canine Implements Pet. The Pet Interface which you can use to be implemented on all Animal subclasses regardless of be them being class Bird for example that would implement the Pet Interface.

Now imagine you have an Animal class which is not abstract, then you may be able to create a new Animal object. But what animal could this be? So it would be better to have an abstract class Animal, which can be extended but not instantiated.
[ September 03, 2005: Message edited by: Megs Maquito ]

I'm a Hood Ornament
kailash mehra
Greenhorn

Joined: Sep 02, 2005
Posts: 2
hi interface can not be private and default but abstract class can have all access modifier's
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Abstract class and interface.