Difference between Abstract Class & Interface?

Answers were Sorted based on User's Feedback



Difference between Abstract Class & Interface?..

Answer / rakesh.fanu

Abstract Class :-
Abstract class should be declare with abstract.
Abstract Class must be extended by its sub class.
Abstract Class has abstract method and also method with
body also.
Abstract Class has not instance variables , it contain only
Constant.
An abstract class cannot be instantiated

Interface :-
Interface must be Implemented by another class.
Interface has only abstract method.
Interface has not instance variables , it contain only Constant.
An Interface cannot be instantiated

Is This Answer Correct ?    6 Yes 2 No

Difference between Abstract Class & Interface?..

Answer / brijendra kumar(xavient)

Abstract Class:

1-Abstact class declare with the abstract keyword.
2-Abstract class contains the both method declaration and
defeination.
3-Abstract class donot have the instant variable.It have
only constrants.
3-Abstract class extended by its sub class.
4-Abstract class support only single inheritence.

Interface:

1-Interface declare with the interface keyword.
2-Interface contains the only collection of method
signature.
3-Interface implement by a class.
4-Interface extended by one or more interfcae.
5-Interface support the multiple inheritence.
6-Interface is useful for java development.

Is This Answer Correct ?    1 Yes 0 No

Difference between Abstract Class & Interface?..

Answer / nivas

abstract class is declared in abstract and instance methods
but were as interface class is declared only in abstract method

Is This Answer Correct ?    0 Yes 0 No

Difference between Abstract Class & Interface?..

Answer / 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

More Java Related AllOther Interview Questions

What is gpt and gpc? : java security

0 Answers  


Why sun introduce concept of anonymous class? What is need and real life use of anonymous class

0 Answers  


1.can i use super keyword in normal class(not inheritance) to call any method?if so how can i call particular variable? 2.In the inheritance how can i access the particular variable from the base class(it containing 5 variables) using super keyword?

0 Answers  


Write a program using call by refernce for two different classes to explain to print whether a given number is automorphic or not.

0 Answers  


Explain the inheritance principle.

0 Answers  






what is reflection api? How are they implemented?

0 Answers  


When a thread is created and started, what is its initial state?

0 Answers  


What is meant by java se?

0 Answers  


Which version of jdk is required for netbeans 8.0 2?

0 Answers  


What is java lang noclassdeffounderror?

0 Answers  


What is optional in java 8? What is the use of optional?advantages of java 8 optional?

0 Answers  


What is an action class in java?

0 Answers  


Categories