Compare an abstract class and an interface , JAVA Programming

You want the base class to represent only an interface for its derived classes. That means, you don't want anyone to actually instantiate an object of the parent class. You only want to upcast to it so that its interface may be used. This is accomplished by building that class abstract using the abstract keyword. If anyone tries to build an object of an abstract class, the compiler saves it.

 

The interface keyword makes this concept of an abstract class a step further by preventing any function or method implementation at all. You can only define a method or function but not give the implementation. The class, which is adding the interface, should give the actual implementation. The interface is a commonly and very useful used aspect in OO design, as it gives the implementation and separation of interface and actives you to:

 

1. Use similarities among unrelated classes without artificially forcing a class relationship.

2. Define methods that one or more classes are expected to implement.

3.  Reveal an object's programming interface without revealing its basic implementation.

4. Model multilevel interface inheritance in Java, which gives some of the benefits of full on multiple inheritances, a feature that some object-oriented languages support that allow a class to have more than one parented class.

 

 

155_Untitled.png

Posted Date: 7/25/2012 1:30:33 AM | Location : United States







Related Discussions:- Compare an abstract class and an interface , Assignment Help, Ask Question on Compare an abstract class and an interface , Get Answer, Expert's Help, Compare an abstract class and an interface Discussions

Write discussion on Compare an abstract class and an interface
Your posts are moderated
Related Questions
1) Central museum is one of the famous tourist places in london. They ask comments from every customer visiting them.  For that, they maintained one register to store visitor;s com

699906626330444777707776662233777 decoding program

What is asynchronous messaging? Queue Ans) Asynchronous messaging includes a client that does not wait for a message from the server. An event is used to trigger a message from

Overall Requirements Every phone number is broken up into sections as shown below: Country Code Area Code Prefix Line Number 1 919 882 5000 Write a program to separate out a ph

Explain Animate gifs? We can save 16 gif images of the previous instance in a single file in the form of an animated gif, and then used it in a regular tag to display a movi

What is the difference between preemptive scheduling and time slicing? Under preemptive scheduling, the highest priority task executes unless it enters the waiting or dead stat

Computer application and program. Project Description: I require a project done. It is a computer desktop application program. It is not very hard. Skills required: Any

EJB elements operate inside a container environment and rely heavily on the container to give security. The four key services needed for the security are: 1. Identification :

Explain Drawing Rectangles in java ? Drawing rectangles is easy. Begin with a Graphics object g and call its drawRect() method: public void drawRect(int x, int y, int width, i

Give an example of Class or static Members? Below is a Car class along with such a speedLimit field and getSpeedLimit() method. public class Car { private String licensePla