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

What is thread safe singleton?

517


What is the largest data type in java?

511


What is the point of java?

554


How are multiple inheritances done in Java?

622


What is sortedmap in java?

553






What is the file extension for java?

612


What is sizeof in java?

559


What is the meaning of variables in research?

533


What is the base class of all classes?

571


How is it possible for two string objects with identical values not to be equal under the == operator?

528


How to compare strings in java?

506


What is the concatenation operator in java?

580


What is casting in java programming?

585


What is a static method in java?

540


What is externalizable?

620