File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Abstract, Interfaces! 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, Interfaces!" Watch "Abstract, Interfaces!" New topic
Author

Abstract, Interfaces!

Anuja
Greenhorn

Joined: Aug 23, 2000
Posts: 14
What is Abstract kayword and Interfaces?
Would you please explained by an example?
Thanks a lot!
Regards,
Anuja
Tony Alicea
Desperado
Sheriff

Joined: Jan 30, 2000
Posts: 3222
    
    5
What Is an Interface?


Tony Alicea
Senior Java Web Application Developer, SCPJ2, SCWCD
Anuja
Greenhorn

Joined: Aug 23, 2000
Posts: 14
Hi Tony,
I appreciate your response.
Thanks a lot,
Regards,
Anuja
Originally posted by Anuja:
What is Abstract kayword and Interfaces?
Would you please explained by an example?
Thanks a lot!
Regards,
Anuja

srikishore koduri
Greenhorn

Joined: Aug 29, 2000
Posts: 3
hi,
the significant diffrence b/w abstract and interface is:
abstract class can have non abstract methods i.e. implemented methods also where as interfaces cann't have.
Venu G Askani
Greenhorn

Joined: Sep 20, 2000
Posts: 7
Abstract keyword is used to define a method as abstract or any class as abstract. A class is defined as abstract when it contains at least one method as abstract. It can contain the other methods that are not abstract. Well interfaces are classes which have all the methods that are not implemented. These came to arise because of the indirect implementation of Multiple Inheritance. The interfaces are designed to implement multiple inheritance. And the abstract classes can be extended by a wide variety of classes that implement that abstract methods.
Hope i explained the query correctly..
Bye
Venu
Originally posted by Anuja:
What is Abstract keyword and Interfaces?
Would you please explained by an example?
Thanks a lot!
Regards,
Anuja

Venu G Askani
Greenhorn

Joined: Sep 20, 2000
Posts: 7
Hi Anuja,
I suppose the difference in the definition is due to the constraint in java of multiple inheritance. The multiple inheritance is done or rather achieved in java by the use of interfaces. In this way you can do multiple inheritance.
Bye
Venu
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Hi,
I just want to add that an abstract class need NOT contain an abstract method. All the methods in a class can be provided implementation and the class can still be abstract by specifying so.
Vani
Sachin Kombrabail
Greenhorn

Joined: Aug 28, 2000
Posts: 14

As per my understanding
1. Both interfaces & abstract classes cannot be explicitly instantiated.
2. Even a single method being defined abstract makes the class abstract.
3. All the methods of an interface HAVE to implemented by the implementor.
4. Unlike a interface, a method of an abstract class can have default implementation.
5. A class can extend a single parent but can implement multiple interfaces.
6. The only thing that a class can inherit from an interface is the message signatures. From an abstract class you can inherit the default implementations.
For a good example take any listener say the WindowListener which is an interface. If you want to implement it you have to implement all the 7 methods that are there in the interface. Now look at the WindowAdapter. This is an abstract class which has implemented all the methods of the WindowListener but all the implementations are empty. To make use of this combination you will have to extend the WindowAdapter and only code that method you want.
Anuja
Greenhorn

Joined: Aug 23, 2000
Posts: 14
To Tony,Srikishore,Venu,Kadur,Sachin

Thanks a bunch !!!
Thank Again all of your response

Regards,
Anuja
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Abstract, Interfaces!