ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   SiteMap shows list of All Categories in this site.
Google
 
Categories  >>  Software  >>  Core Java  >>  Java J2EE  >>  Java Related
 
 


 

 
 Core Java interview questions  Core Java Interview Questions
 Advanced Java interview questions  Advanced Java Interview Questions
 Swing interview questions  Swing Interview Questions
 EJB interview questions  EJB Interview Questions
 Servlets interview questions  Servlets Interview Questions
 Struts interview questions  Struts Interview Questions
 JDBC interview questions  JDBC Interview Questions
 JMS interview questions  JMS Interview Questions
 SunOne interview questions  SunOne Interview Questions
 J2EE interview questions  J2EE Interview Questions
 Weblogic interview questions  Weblogic Interview Questions
 Websphere interview questions  Websphere Interview Questions
 Java Networking interview questions  Java Networking Interview Questions
 Java J2EE AllOther interview questions  Java J2EE AllOther Interview Questions
Question
when to use abstract class and when to use interface?
 Question Submitted By :: Raghu
I also faced this Question!!     Rank Answer Posted By  
 
  Re: when to use abstract class and when to use interface?
Answer
# 1
Abstract(patially implemented) class can be used as a 
common base class for an application it has all property of 
class except it cannot be instantiated.it provide default 
behavior.

interface is mearly a specification,nothing implemented for 
any standalone project which can be changed at will its 
more design flexible and it can be utilized to model 
multipleinheritance.
 
Is This Answer Correct ?    13 Yes 4 No
Muthusenthil
 
  Re: when to use abstract class and when to use interface?
Answer
# 2
Hi...
When u want to inherit the properties of base class only
(not other resources) go for Abstract class.
When u want to inherit the properties of base class and 
other resources go for Interfaces .
 
Is This Answer Correct ?    11 Yes 3 No
Devarathnam C,kotagudibanda(po
 
 
 
  Re: when to use abstract class and when to use interface?
Answer
# 3
abstract class is used if you are willing to restrict the 
creation of an instance.
interface is used if you are willing to write different 
functionalities in different implementations.
 
Is This Answer Correct ?    9 Yes 2 No
Ravikiran
 
  Re: when to use abstract class and when to use interface?
Answer
# 4
In Interfate you are restricting a user to impement each 
and every method of interface so if you have a requirement 
which is  constantly changing so don't prefere interface.

While in Abstract Class user don't need to implement each 
and every method which is not required or marked with 
mustoverride.


And by using interface you can achive multiple inheritance 
in C# but with Abstact class it's can't be achive
 
Is This Answer Correct ?    11 Yes 3 No
Mohit Jethva
 
  Re: when to use abstract class and when to use interface?
Answer
# 5
Abstract provides both methods with and without body. 
Adding new methods in abstract class in middle of 
development life cycle won't break existing sub classes 
unless these methods are declared as mustoverride. If there 
are frequent addition of new methods properties and so on. 
one should use abstract..

Whereas on the other hand interface can fill gap of 
multiple inheritance. One can
implement from more than one interface. Not same with 
Abstract. One can inherit
from only one abstract class.
 
Is This Answer Correct ?    2 Yes 0 No
Amit
 

 
 
 
Other Core Java Interview Questions
 
  Question Asked @ Answers
 
Explain in detail about encapsulation with an example?  3
Can you have a constructor in abstract class?  7
What services that container provides?  1
what is difference Between Core Java and advance java HCL19
what are depricated methods ? Satyam4
Is &&= a valid Java operator?  2
Can try statements be nested? Wipro2
What is run-time class and system class? what is their purpose?  1
What is more advisable to create a thread, by implementing a Runnable interface or by extending Thread class?  5
explain System.out.println IBM41
What are other modifiers? Wipro1
what is features of jdk 1.5? TCS2
what is the difference between abstract class and Interface?where we can use it in realtime projects? Logica-CMG10
what is multitherading Tech-Mahindra2
whats is the use of final,in which situation final can be used in the application? DNS2
Are there any tools available in java to create reports?  5
How can a class be accessed, If no access modifiers are declared?  2
How can final class be used? Wipro2
To set the position and size of a component, which methods are used?  2
question on Thread synchronization Huawei1
 
For more Core Java Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com