GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

GeekInterview.com  >  Interview Questions  >  J2EE  >  OOPS
Go To First  |  Previous Question  |  Next Question 
 OOPS  |  Question 26 of 31    Print  
What is the need of an abstract class?
If I write all of concrete methods in one class and all abstract methods in an interface and extend and implement both in third class assume that third class don't extend any other class?


  
Total Answers and Comments: 4 Last Update: August 16, 2008     Asked by: Chandrashekhar 
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: ramesh.sukka
 

Providing the Abstract functionality to object is one of the powerful concepts by java, I will give you one sample scenarios where you required implement the abstract class,

 

Assume that you are going to design TV remote (in real time it will be your client business) with 100 new functionalities in it but you know only 30 functionalities to implementation at this moment. So you will provide implementation for 30 method and rest of 70 methods are abstract. When ever new class extends it, it should be implement rest of 70 methods.



Above answer was rated as good by the following members:
shilpad
October 23, 2007 08:57:33   #1  
sarithahere528 Member Since: October 2007   Contribution: 10    

RE: What is the need of an abstract class?
U need to implement all the methods of interface and if u want u can override methods of extended class  ...
 
Is this answer useful? Yes | No
November 17, 2007 16:12:58   #2  
ramesh.sukka Member Since: November 2007   Contribution: 7    

RE: What is the need of an abstract class?

Providing the Abstract functionality to object is one of the powerful concepts by java, I will give you one sample scenarios where you required implement the abstract class,

 

Assume that you are going to design TV remote (in real time it will be your client business) with 100 new functionalities in it but you know only 30 functionalities to implementation at this moment. So you will provide implementation for 30 method and rest of 70 methods are abstract. When ever new class extends it, it should be implement rest of 70 methods.


 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
February 13, 2008 04:20:50   #3  
sampra Member Since: February 2008   Contribution: 279    

RE: What is the need of an abstract class?
If we have some method which body is not defined till declartion of class and body is implemented in subclass later then declare that class as abstract class.If a class has atlest one abstract method then we have to declare class as abstract class

 
Is this answer useful? Yes | No
August 15, 2008 12:02:07   #4  
alkumar2000 Member Since: August 2008   Contribution: 5    

RE: What is the need of an abstract class?
Abstract is most useful when you are creating a framework..take the example of template method pattern which is used in the templates provided by spring framework for the support of jdbc or hibernate it absrtacts out all the common things which needs to be done in the templates that it provides the only thing now the developer has to do is to extend these classes create and execute the query.The develepor here doesn't need to worry to get the connection and close the connection.
 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 




About Us  |   Privacy Policy  |   Terms and Conditions  |   Contact  |   Site Map  |   Add Question  |   Propose Category  |   RSS Feeds  |   Articles Sitemap  |   Site Updates  |   Add Resource

Copyright © 2005 - 2008 GeekInterview.com. All Rights Reserved
Page copy protected against web site content infringement by Copyscape