?
Solved

interface and abstract class

Posted on 2011-09-07
5
Medium Priority
?
451 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 4

Accepted Solution

by:
SafetyFish earned 1000 total points
ID: 36495735
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 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.
0
 
LVL 60

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.
0
 
LVL 4

Expert Comment

by:SafetyFish
ID: 36912527
Sounds good to me.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses
Course of the Month10 days, 16 hours left to enroll

770 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