When should I use abstract classes and when should I use
interfaces?

Answers were Sorted based on User's Feedback



When should I use abstract classes and when should I use interfaces?..

Answer / ved.b.tripathi

Interface : when you about to maintain the standard through
out the application then,blindly go with the interface.

Abstract : when you customize the behavior but still want to
maintain some standard then use abstract,because in abstract
you can have non abstract method that will be use by every
class that extend this abstract method and that class also
have to give the body of abstract methods(standard).

Is This Answer Correct ?    15 Yes 2 No

When should I use abstract classes and when should I use interfaces?..

Answer / ankit

if u r required more than 1 class in ur prog then use
interface because u cant extends 2 class in ur prog ...to
use 2 class in ur prog u can implement 1 interface and
extends 1 class

Is This Answer Correct ?    1 Yes 1 No

Post New Answer

More Core Java Interview Questions

There are 2 classes, 1 LandAnimal and another WaterAnimal. There is another class Animal which wants to have the properties of both LandAnimal and WaterAnimal. How will you design this situation?

6 Answers   KPIT,


Can we nested try statements in java?

0 Answers  


we cannot create an object of interface but we can create a variable of it

1 Answers  


What are the performance implications of interfaces over abstract classes?

1 Answers  


What do you understand by Header linked List?

0 Answers   Genpact,






We can write any Java Logics in our JSP. Then why we are using servlets(Controller Layer) to interact with the DAO ?

6 Answers   TCS,


What is the default size of arraylist in java?

0 Answers  


What is garbage collection in Java, and how can it be used ?

32 Answers   Accenture, HCL, Infosys, Sara, SITS, TCS, Wipro,


Which is better stringbuilder or stringbuffer?

0 Answers  


Is call by reference possible in java?

0 Answers  


Why is java so popular?

0 Answers  


What is a J2EE component? List out all the component?

2 Answers   Adobe,


Categories