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


Please Help Members By Posting Answers For Below Questions

How many bytes are a float?

511


What is a layout manager and what are different types of layout managers available in java awt?

731


What are thread safe functions?

518


What are the advantages of unicode?

551


Does anyone still use java?

588






Why runnable interface is used in java?

578


what is instanceof operator used in java?

597


What does compareto () do in java?

578


What are different types of constants?

522


What is java virtual machine and how it is considered in context of java’s platform independent feature?

659


What is the difference between call by reference and call by pointer?

507


what is deadlock? : Java thread

529


What is a null check?

542


How do you use substring in java?

552


Explain the key functions of data binding?

589