• 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
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

interface and abstract

 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am little bit confused about interface and abstract.
I found this question in onesite.
8) What is the difference between interface and an abstract class?
Ans : All the methods declared inside an Interface are abstract. Where as abstract class must have at least one abstract method and others may be concrete or abstract.
*I checked WindowListener interface in java API, but i didn't
get any abstract method. I think abstract keyword should be
written before the method.
Can anyone clarify that,

 
Ranch Hand
Posts: 439
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
methods in an interface are implicitly abstract therefore you have to implement them in your class. Inteface is also itself implicitly abstract.
 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, Golam Newaz:
You are right the answer is not fully correct.
It Should be like this
Ans :
All the methods declared inside an Interface are abstract.(true)
- you can't have non abstract methods
Where as abstract class must have at least one abstract method and others may be concrete or abstract (No).
-It is not a must to have an abstract method in a Abstract Class.
Siva
 
Golam Newaz
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Val and siva, both of you are correct. But my question came in different way. I want to know why abstract modifier is dropped out of interface and of methods. After reviewing your reply, i
checked java.sun.com and found the following which actually
i was looking for.
1. abstract interfaces:
- Every interface is implicitly abstract. This abstract modifier is obsolete and should not be used in new programs.
2. abstract methods of the body of abstract interface:
For compatibility with older versions of the Java platform, it is permitted but discouraged, as a matter of style, to redundantly specify the abstract modifier for methods declared in interfaces.
It is permitted, but strongly discouraged as a matter of style, to redundantly specify the public modifier for interface methods.
Am i right.
- Golam Newaz
------------------
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic