Abstract Classes

  • Simran
  • Born
  • Born
  • No Avatar
  • Joined: Jan 04, 2009
  • Posts: 3
  • Status: Offline

Post January 4th, 2009, 10:46 pm

Hello,
Please tell me What is an Abstract classes? Please tell me.I'm waiting for your reply.

Thanks In Advance. :idea:
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post January 4th, 2009, 10:46 pm

  • spork
  • Brewmaster
  • Silver Member
  • User avatar
  • Joined: Sep 22, 2003
  • Posts: 6128
  • Loc: Seattle, WA
  • Status: Offline

Post January 5th, 2009, 12:22 am

Abstract classes are classes that can be defined but not instantiated. They often contain abstract methods, which require subclasses that inherit from the abstract class to define the behavior for such methods.

For example, I may be writing a program that manages employees. Say my company has two types of employees - hourly and salaried. I could create two classes to represent them: HourlyEmployee and SalariedEmployee.

But since the two classes have a lot of data/functionality in common (name, position, etc), I'd want to place that information in a common superclass, Employee, and have my two specific employee classes extend it.

But since employees must be of one type or the other, we don't want the Employee class to ever be instantiated directly -- we must force instantiation of the subclasses. For this reason, we make the Employee class abstract.

Additionally, say we had a method in our class called getPayRate(). This method will exist for both employee types, but its functionality will be different for each type. We can declare getPayRate() as an abstract method in our abstract Employee class. This forces HourlyEmployee and SalariedEmployee to define the behavior individually.

http://en.wikipedia.org/wiki/Abstract_type

http://www.javacoffeebreak.com/faq/faq0084.html

http://msdn.microsoft.com/en-us/library/c8whxhf1.aspx

(grunt..)
The Beer Monocle. Classy.

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: Zealous and 155 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.