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  >  Placement Papers  >  HP (Hewlett-Packard)  >  Technical
Go To First  |  Previous Question  |  Next Question 
 Technical  |  Question 14 of 21    Print  
What are interfaces, abstract classes. What is their purpose and differences ?

  
Total Answers and Comments: 3 Last Update: December 09, 2005   
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
July 24, 2005 13:13:06   #1  
Vijaya Bhaskar M        

RE: What are interfaces, abstract classes. What is their purpose and differences ?
By default all methods present in the interfaces are abstract. where as we can provide mthod definition in the abstract class but we cont provide body to a method in the interface. 
Interfaces provides multiple inheritance in java.  
abstract classes provides the facility to extend the functionality of a class.

 
Is this answer useful? Yes | No
August 25, 2005 10:38:10   #2  
Binod        

RE: What are interfaces, abstract classes. What is their purpose and differences ?
Interfaces: 
We can define only methods, no implementation. 
All methods are abastract. 
We can define variables, but those shld be constants. 
 
Abstract classes 
Class which conatains one or more abstarct menthods or class which is marked as abstarct. 
We can have implementation inside this class. 
This class in meant to be extended by some other class, subclasses will provide implementation for abastarct methods. 
 
Interfaces are a way of implemention multiple inheretence in java. 
 
Choice of usage depends on design decision.

 
Is this answer useful? Yes | No
December 09, 2005 10:50:12   #3  
sahu Member Since: December 2005   Contribution: 324    

RE: What are interfaces, abstract classes. What is the...

Ans:

Abstract Class:
Instance can not be created. Optionally can have one or more abstract methods but not necessary. Can provide body to Classes.

Interface:
What a Class must do, But not how-to.
Bridge for the communication when the caller does not know to whom he is calling.
Describes externally visible behavior of element.
Only Public members which defines the means of the communication with the outer world. Can-be-Used-As Relationship.
Can not contain data but can declare property. There can be no implementation. Interface can be derived from another interface

 

Difference between Abstract class and interface

In an interface class, all methods are abstract - there is no implementation.  In an abstract class some methods can be concrete.  In an interface class, no accessibility modifiers are allowed.  An abstract class may have accessibility modifiers


 
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