what is difference between Interface and abstract class

Answer Posted / surender kannuri

interface is a specification of method prototype.

all methods in interface are abstract and final.

interface methods are public since they should be available
to third party vendor to provide implementation.they are
abstract because their implementation is left for third
party vendors.


interface contains 0 or more abstract methods.

all methods of interface should implemented in implemented
class.if any method is not implemented then implementation
class should be declared as abstract.

we can't create object to interface.but we can create
reference to interface type.

an interface contains variables ,such as public.static and
final variables.this means all variables of interface are
constant.

an interface cannot implements another interface.
an interface can extend another interface.

it is possible to write a class within an interface.
a class can implements(not extend) multiple interfaces.


abstract class contains 0 or more abstract methods.
all methods of abstract class should be implemented in
subclasses only.
all methods of abstract class should be declared by using
abstract keyword.
we can't create an object to abstract class.

Is This Answer Correct ?    1 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the name of the java compiler?

521


What does indexof mean?

530


What is the basic difference between string and stringbuffer object?

579


What is the significance of listiterator?

567


Can we override protected method in java?

578






How can we create a thread in java?

585


How do you add an element to an arraylist in java?

485


Explain how to force the garbage collection in java.

531


Write a program to solve producer consumer problem in java?

567


What are thread groups?

571


Can we use catch statement for checked exceptions?

511


What do you mean by singleton class in java?

514


When can you say a graph to be a tree?

637


What is the use of generics? When was it added to the Java development Kit?

553


When do we use hashset over treeset?

531