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
What is the use of UnicastRemoteObject in RMI? Ans) The UnicastRemoteObject class gives support for point-to-point active object references using TCP streams. Objects that need

Differentiate between onLoad and onUnload? Onload executes the particular javascript code when a latest document is loaded into a windows. ONUnload executes he particular javas

Smugglers are becoming very smart day by day. Now they have developed a new technique of sending their messages from one smuggler to another. In their new technology, they are send

What is Color in AWT? Color is a class in the AWT. Individual colors such as red or mauve are examples of this class, java.awt.Color. Be sure to import it if you want to use ot

short Java application that stores words in an Array or ArrayList.

Your task is to design a scheduler for the Sheridan Rail Corporation which keeps track of all daily scheduled trips for the railway.  Users can add new trips as well as perform sea

What is an intelligent system? Intelligent system is a SW programs or SW and HW systems designed to perform complex tasks employing strategies in which mimic some aspect of hum

What is JavaServer Faces event and listener model? Ans) A mechanism for verifying how events emitted by JavaServer Faces UI components are handled. This model is based on the Ja

Design a logic circuit to convert Gray code to Binary code and draw the logic circuit.

An application server cluster has of a number of application servers loosely coupled on a network. The server group or server cluster is usually distributed over a number of nodes