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
J2EE Java Website rebuild Project Description: We are seeking an experienced developer to re-build a Java/J2EE based Website. We are in requirement to reconstruct our website

Why are JSP pages the preferred API for creating a web-based client program? Because no plug-ins or security policy files are required on the client systems (applet does). Also,

I'm seeking to hire someone to build me a program that can solve a php captcha. It should be a web service or script. You will write it in any language since i will execute i ca

We require responsible and serious programmer Project Description: Big Data and On-line tools Website Liferay - JAVA - Portlets - JSP and JSF Skills required: J2EE,

JMS ((java messaging service))is an acronym used for Java Messaging Service. It is Java's answer to formed software using asynchronous messaging. It is one of the official specific

What is difference between Design and System Architecture? System Architecture : It is structure of a product or procedure. Design: It is begin of the procedure of devel

How we Use a Car object in a different class ? class Car { String licensePlate; // e.g. "New York 543 A23" double speed; // in kilometers per hour double maxSpeed;

For this assignment you are provided with a class called LNode which can be used as a list node for a linked list of ints. You are also provided with an abstract class called LList

public class TreeTest {     public static void main(String args[])     {         Tree t = new Tree ();         System.out.println("Populating");         t.insertItem(1);         t

Explain The Methods of java.lang.Object? java.lang.Object gives a number of methods that are general to all objects. toString() is the most general such method. Because the def