Difference between Abstract Class & Interface?

Answer Posted / adikeanand@gmail.com

ABSTRACT CLASS:
1)abstract class contains abstract methods with body and concrete methods also.
2) when a class contains abstract methods declare the class as abstract.
3) when we don't want to allow anybody to create object to the class then declare class as abstract.when we want to use the methods of a abstract class write a class which extends abstract class and create reference variable to abstract class and assign subclass object.
4)We can not create object to the abstract class but we can create reference variable.

INTERFACE:
1)Interface contains abstract methods and static final data.
2)when we are writing a class which implementing interface then we have to provide the body for all the abstract methods of interface.
3)If we don't want to provide all the methods of interface then declare the class as abstract.write the class which extends abstract class and write the methods which you have left abstract methods and create reference variable to interface and assign the object of class which extends abstract class.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between swing and awt components?

639


What is map and flatmap?

613


What is the java api?

490


Is java installed on windows 10?

472


What is interceptor in java?

465






What is the meaning of the words public, static and void?

474


What's a code group? : java security

528


What are jdk tools?

468


What is meant by rest api in java?

468


What is persistence xml in java?

495


What is java lang exceptionininitializererror?

490


Which version of my browser should I use? : java security

502


What happens when the parent process of a child process exits before the child ?

542


What is the difference between a jdk and a jvm?

490


Explain main thread under thread class execution?

483