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

Answer Posted / varun kumar

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 ?    3 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How we can execute any code even before main method?

555


Does java allow overriding static methods ?

632


What is the best way to findout the time/memory consuming process?

556


Break statement can be used as labels in java?

554


Explain the different forms of polymorphism?

571






Why is inheritance used in java?

609


What is the difference between menuitem and checkboxmenu item?

784


What lambda means?

545


Which is faster call by value or call by reference?

501


What is a treeset class?

560


Is a boolean 1 bit?

614


Where can I find jdk in my computer?

468


How many types of equations are there?

544


How do you reverse a string in java?

583


What is string [] java?

530