Solved

interface and abstract class

Posted on 2011-09-07
5
375 Views
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
0
Comment
Question by:gudii9
  • 2
5 Comments
 
LVL 4

Accepted Solution

by:
SafetyFish earned 250 total points
Comment Utility
This seems like a pretty simple explanation to me:

http://flylib.com/books/en/1.489.1.30/1/

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:

http://www.startvbdotnet.com/oop/abstract.aspx

This also seems like it is a good article:

http://www.javaworld.com/javaworld/javaqa/2001-04/03-qa-0420-abstract.html

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

http://mindprod.com/jgloss/interfacevsabstract.html
0
 
LVL 1

Assisted Solution

by:amirms
amirms earned 250 total points
Comment Utility
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.
0
 
LVL 59

Expert Comment

by:Kevin Cross
Comment Utility
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0
 
LVL 4

Expert Comment

by:SafetyFish
Comment Utility
Sounds good to me.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This video teaches viewers about errors in exception handling.

744 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now