• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Interface and abstract class

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi.....

I have the knowledge of what is an interface and abstract class,But where exactly we have to use interface and abstract class??? Please Explain me with example....... ???
 
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As you know the difference between Interface and Abstract class, you must be knowing that when we implement any Interface, we need to implement all methods in interface, but this is not the case with abstract classes, abstract class can exist without abstract function, and hence if we extend extend class you can override the methods of your interest only.

Example: if yo want to write event on MouseClick only, then there is no need to use MouseListener interface for it, you can simply use MouseAdapter and override required method. And if you want to write code for every event generated by mouse you can use MouseListener interface .
 
Sheriff
Posts: 22849
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nagul, please SearchFirst. This question has been asked so many times we even have an FAQ entry for it.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic