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

Answer Posted / chitij mehrotra

1 A class may inplement several interfaces. A class may
extend only one abstract class.
2 An interface can have only abstract methods. An abstract
class can have both abstract methods and concrete methods.
At one abstract method in the abstract class.
3 Interfaces cannot have constructors. Abstract class can
have constructors.
4 Only static final variables are allowed to be decelared.
Both static and instance variables are allowed.
5 All decelared methods are implicitly public. Can have any
kind of methods.
6 We should initialize variables in an interface. Not
necessary to initialize variables in an abstract class.
7 In the case of interface you can make any class in the
hierarchy. In the case of abstract class you know the class
hierarchy in advance.
8 An interface implementation may be added to any existing
third party class. A third party class must be rewritten to
extend only from the abstract class.
9 Interfaces can be implemented by classes that are not
related to one another Abstract classes are used only when
there is a “is-a” type of relationship between the classes.

Is This Answer Correct ?    54 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

which one is more efficient int x; 1. if(x==null) 2.if(null==x) state which one either 1 or 2?

10012


What is the difference between the prefix and postfix forms of the ++ operator?

754


How do you use compareto in java?

729


How many types of literals are there in JAVA?

757


What are drawbacks of singleton class?

688






What are the skills required for core java?

729


Is map ordered in java?

695


What is the difference between access specifiers and access modifiers in java? 16

717


os is developed in c no java is more secured then c na why dont the os developed is developed using java

3800


What is defined as false sharing in the context of multithreading?

740


What does null mean in java?

817


What is the difference between array list and vector in java?

699


What is difference between final and immutable?

752


What lambda means?

744


What is jvm? Why is java called the platform independent programming language?

751