what is difference between abstract and interface?
can i give real time example for the two topics?
Answer Posted / madhu samala
abstract is a keyword which can be applied to a class or a
class method. When we declare a class as an abstract one,
it may contain the abstract methods. Abstract method is a
method which contains only the declaration but not the
definition (body). The body for this method will be
provided in it's derived classes.
Note: An abstract class may not contain any abstract
method, but if it contains it must be declared as an
abstract class.
An interface is a contract. The contract will be between
the interface and the class.
An interface only contains abstract methods.i.e. They
contain only the method definition not the body.
The body for these methods must be provided inside the
class which implements that interface. If it doesn't
provide then it has to be declared as abstract.
| Is This Answer Correct ? | 12 Yes | 0 No |
Post New Answer View All Answers
When object is created and destroyed?
What is return type in java?
What is thread start?
What is prefix of a string?
Discuss 2D arrays.
Explain abstract class in java?
How can we create a thread in java?
Can we use different return types for methods when overridden?
How to set the permissions to a file in java?
What is an interoperable application in java ?
Can an arraylist be empty?
What function extracts specified characters from a string?
What is a class object?
Is 64bit faster than 32 bit?
What is the difference between method overriding and overloading?