What is the difference between abstract class and interface?

Answers were Sorted based on User's Feedback



What is the difference between abstract class and interface?..

Answer / ranganathkini

An interface is purely contractual in that it only defines
method headers but no implementation. Classes that implement
the interface must provide implementation to all method
defined by the interface.

An abstract class contains partial implementation, i.e. it
provides implementation for some methods where as just
defines abstract method headers for other. Abstract classes
cannot be instantiated directly and have to be extended by
subclasses who implement the abstract methods defined in the
abstract superclass. Unlike an interface, subclasses of the
abstract class only need to implement only those methods
that are marked abstract.

Is This Answer Correct ?    6 Yes 0 No

What is the difference between abstract class and interface?..

Answer / venu

A programer uses an abstract class when there are some
common features of the program shared by all the objects.
A programer uses an interface when all the features of the
program are implements differently for different objects.

Is This Answer Correct ?    3 Yes 1 No

What is the difference between abstract class and interface?..

Answer / 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

More Core Java Interview Questions

What are the elements of java?

0 Answers  


Define how objects are stored in java?

0 Answers  


Can you call one constructor from another if a class has multiple constructors?

0 Answers  


Can an exception be rethrown?

4 Answers   Wipro,


What is the exact difference in between Unicast and Multicast object ?

4 Answers   Accenture,






What is meant by class loader? How many types are there?

0 Answers  


Can we use String with switch case?

0 Answers  


What is runtime polymorphism or dynamic method dispatch?

0 Answers  


Difference between array and arraylist.

23 Answers   Arise Solution, Banca Sella, iFocus, NIC, Sai Softech, Solartis, TCS, Verizon,


How many classes can any class inherit java?

0 Answers  


When can you say a graph to be a tree?

0 Answers   Amazon,


How do you represent a space in regex java?

0 Answers  


Categories