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 are the string methods in java?

0 Answers  


when i write string s1="java"; in one program(application) and string s2="java"; in another application on the same jvm will both objects s2,s2 will refer to same memory location where "java" is stored in string pool.

2 Answers  


Difference between this() and super() ?

0 Answers  


What is the formula to calculate percentage?

0 Answers  


why we import both packages java.awt.*; and java.awt.event.*; as java.awt.*; can import all classes na. then what is the need of importing java.awt.event.*; ?

3 Answers  


Does treeset allow null in java?

0 Answers  


Give few examples of final classes defined in Java API?

0 Answers   BirlaSoft,


Difference between == and .equals() ?

0 Answers  


Can I overload to string method

0 Answers   UHG,


What is the difference between the jdk 1.02 event model and the event-delegation model introduced with jdk 1.1?

0 Answers  


What interface is extended by awt event listeners?

0 Answers  


wht is customised exception?

1 Answers   Logica CMG, Novell, Prudential,


Categories