What is the difference between abstract class and interface?

Answer Posted / srikanth reddy

1. Abstract classes may have some executable methods and
methods left unimplemented. Interfaces contain no
implementation code.
2. An class can implement any number of interfaces, but
subclass at most one abstract class.
3. An abstract class can have nonabstract methods. All
methods of an interface are
abstract.
4. An abstract class can have instance variables. An
interface cannot.
5. An abstract class can define constructor. An interface
cannot.
6. An abstract class can have any visibility: public,
protected, private or none
(package). An interface's visibility must be public or none
(package).
7. An abstract class inherits from Object and includes
methods such as clone() and
equals().

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain how to convert any java object into byte array.

767


How to avoid memory leak in java?

857


What is collection sort in java?

777


What is difference between adapter class and listener?

730


What is arrays fill in java?

773


Write a program in java to calculate the difference between the sum of the odd level and even level nodes of a binary tree.

776


Is it possible to write a regular expression to check if string is a number?

800


What do you know about the garbage collector?

892


What is difference between c++ and java ?

892


What are synchronized methods ?

847


What are implicit objects in java?

769


What is java full form?

738


Why is stringbuffer thread safe?

827


What’s the difference between the methods sleep() and wait()?

791


How an object is serialized in java?

767