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 will happen when using pass by reference in java?

514


What is namespace in java?

541


Is ++ operator is thread safe in java?

512


how we can create packages in java?

512


Give a practical example of singleton class usage?

585






What is meant by 'bit masking' in java?

642


Is null function in java?

562


What is method overriding in java ?

650


What is the difference between superclass and subclass?

539


How do you sort a string in alphabetical order in java?

525


What are annotations in java?

619


How java is similar to c?

582


What is the full form of jpeg?

511


What is identifier with example?

564


Difference between character constant and string constant in java ?

551