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

Question: (a) Discuss the Java approach to event processing by explaining how event handling works in Java. Use an example to support your answer. (b) Explain what is a ‘

Write a program using local variable Public void someMethod( ) { int x; //local variable System.out.println(x); // compile time error } - Constructor - Doesn't

Need Simple Desktop Software I am seeking a software that can do the subsequent: 1. Check position for a URL in Google, Yahoo, Bing. 2. Check position for a YouTube video

Ask question ##title.. ????? ?????#title.. ????? ?????#title.. ????? ?????Minimum 100 words accepted#

My name is Myers, the project director of an online business that is scheduled to commence this summer in Nigeria. We are in the process of recruiting members to the project team a

The flow control statements give you to conditionally execute statements, to repeatedly operate a block of statements, or to just modify the sequential flow of control.

Interface to calculate carbon foot print

Luminous Jewels - The Polishing Game Byteland county is very famous for luminous jewels. Luminous jewels are used in making beautiful necklaces. A necklace consists of various lum

The statechart diagrams and activity diagram are related in a sense that statechart diagram refers on object undergoing a transition process and an activity diagram refers on the f