• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Abstract, Interfaces!

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is Abstract kayword and Interfaces?
Would you please explained by an example?
Thanks a lot!
Regards,
Anuja
 
Desperado
Posts: 3226
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What Is an Interface?
 
Anuja
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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


 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To Tony,Srikishore,Venu,Kadur,Sachin

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

Regards,
Anuja
 
I just had the craziest dream. This tiny ad was in it.
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic