It's not a secret anymore!*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes interface and abstract Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "interface and abstract" Watch "interface and abstract" New topic
Author

interface and abstract

Golam Newaz
Ranch Hand

Joined: Jan 08, 2001
Posts: 64
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,

Val Dra
Ranch Hand

Joined: Jan 26, 2001
Posts: 439
methods in an interface are implicitly abstract therefore you have to implement them in your class. Inteface is also itself implicitly abstract.


Val SCJP <BR>going for SCJD
Sivalingam Sivasuthan
Ranch Hand

Joined: Jan 12, 2001
Posts: 75
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


- Siva<br /> Sun Certified Programmer for the Java™2 Platform
Golam Newaz
Ranch Hand

Joined: Jan 08, 2001
Posts: 64
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
------------------
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: interface and abstract
 
Similar Threads
interface
Diff bw Abstract class and Interface
interface and abstract class
ABSTRACT
Regarding abstract class