abstract class

  • Thread starter Thread starter Peter
  • Start date Start date
P

Peter

An Abstract Class is a class that represents abstract concepts for which
objects cannot exist.
Instances of abstract classes cannot be created. When is it advisable to
implement an abstract class (instead of Interface)?
 
Peter said:
An Abstract Class is a class that represents abstract concepts for which
objects cannot exist.
Instances of abstract classes cannot be created. When is it advisable to
implement an abstract class (instead of Interface)?

An interface can't have *any* code, an abstract baseclass
can contain some code.

I think the general rule is:
if it is (deep down) "the same", use a (possibly abstract) baseclass.
if it is different, but just should *act* the same, use an interface.
 
How about:

You implement an AC to create multiple versions of a component, since it
provides a simple and easy way to version your components. By updating the
base class, all inheriting classes are automatically updated with the
change.

Chris
 
hi
If you have atleast one concrete implementation of a method you can go for
abstract calss

remember am abstract calss can have methods with implementation

Another diffrence is that an interface method definition can have access
modifier only as public,while an abstract calss method has no such
constrain


regards
Ansil .F
Trivandrum
 
Back
Top