interface and abstract class

Posted on 2011-09-07
Medium Priority
Last Modified: 2012-05-12
i would like to know about interface and abstract classes.
i read as
you need some classes to use some methods which you don't want to be included in the class, then you go for the interface, which makes it easy to just implement and make use of the methods defined in the interface.

abstract classes when
Abstract classes are an excellent way to create planned inheritance hierarchies. They're also a good choice for nonleaf classes in class hierarchies.

I am not clear on this this explanation. Thanks in advance
Question by:gudii9
  • 2

Accepted Solution

SafetyFish earned 1000 total points
ID: 36495735
This seems like a pretty simple explanation to me:


This is short, but sweet and seems to include a nice example of simple code for abstract classes and members. Comparison to interfaces is only cursory:


This also seems like it is a good article:


I really like the comparison table between the two on this website:


Assisted Solution

amirms earned 1000 total points
ID: 36501120
Interface is simply an abstract class which all of its methods are abstracts i.e. non of the methods have implementations. An abstract class in contrast can include implemented methods (i.e. methods which already contain functional work and are simply inheritted to the children classes) an Interface does not contain implemented methods i.e all the methods in there are just declared so that the children can implement them.

Basically, if the children of a parent class have no common implementation of methods which they inherit, we define their parent as an abstract. For example if parent class "Shape" has only one non-private abstract method called "Draw()" and its two children classes namely "Circle" and "Rectangle" do not have a same way of drawing themselves, we could simply define "shape" as an abstract class and leave "Circle" and "Rectangle" to draw themselves however they are required to by implementing the "shape" class.
LVL 61

Expert Comment

by:Kevin Cross
ID: 36935270
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.

Expert Comment

ID: 36912527
Sounds good to me.

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

A solution for Fortify Path Manipulation.
A discussion about automated testing of Web Applications utilizing Selenium, along with illustrated configuration steps for the Jenkins open source tool.
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses

619 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question