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

 Print  |  
Question:  What are interfaces, abstract classes. What is their purpose and differences ?



December 12, 2005 10:50:12 #3
 sisira Microsoft Expert  Member Since: December 2005    Total Comments: 323 

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

     

 

Back To Question