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

What is a newline character in java?

0 Answers  


What are bind parameters?

0 Answers  


java is puerly object oriented or not ?

5 Answers  


Can an arraylist be empty?

0 Answers  


What is the format of Inner Class after it compiled?

1 Answers  






IN java collections we have both interfaces and classes. instead of using interfaces why we can't use classes only like that why we can't use interfaces only. why we need two things interface and class.

6 Answers   Accenture, CTS,


what is the Use of throws exception?

2 Answers  


Can you create an object of an abstract class?

0 Answers  


What is floor math?

0 Answers  


what is the swingutilities.invokelater(runnable) method for? : Java thread

0 Answers  


What is static variable with example?

0 Answers  


Can array grow dynamically in java?

0 Answers  


Categories