what is the difference between abstract class and
Interface?where we can use it in realtime projects?

Answer Posted / arvind

1.interface contains methods that must be abstract;
abstract class may contain concrete methods.
2.interface contains variables that must be static and
final; abstract class may contain non-final and final
variables.
3.members in an interface are public by default, abstract
class may contain non-public members.
4.interface is used to "implements"; whereas abstract class
is used to "extends".
5.interface can be used to achieve multiple inheritance;
abstract class can be used as a single inheritance.
6.interface can "extends" another interface, abstract class
can "extends" another class and "implements" multiple
interfaces.
7.interface is absolutely abstract; abstract class can be
invoked if a main() exists.
8.interface is more flexible than abstract class because
one class can only "extends" one super class,
but "implements" multiple interfaces.
9.If given a choice, use interface instead of abstract
class.

Is This Answer Correct ?    1 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Write a program in java to create a doubly linked list containing n nodes.

727


What is the difference between the direct buffer and non-direct buffer in java?

766


Is java a digit method?

731


List some oops concepts in java?

774


Explain naming conventions for packages?

763


Does sprintf allocate memory?

805


How do you read a char in java?

685


How is java hashmap implemented?

758


What does substring mean?

693


can java object be locked down for exclusive use by a given thread? : Java thread

764


Is integer immutable in java?

730


What is the purpose of the enableevents() method in java programming?

789


how to know the total memory occupied by the objects in the ArrayList(Array list may contain duplicate objects)

2102


What is type parameter in java?

710


What do you mean by multithreaded program?

752