Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Abstract classes are used to define a class that will be used only to build new classes.
- No objects will ever be instantiated from an abstract class. Abstract classes are used to create hie-
- rarchies of classes.
- Any sub class that extends a super abstract class must implement all methods defined as abstract in the
- super class unless the extending class is abstract class.
- Abstract classes are great when you know quite a bit about an Object, but not everything.
- For instance, say you are writing a program to simulate flying objects and you know that
- all of the objects will have width, height, and speed, but you do not know how each one will fly.
- The fly properties and behavior will differ for each type of flying object which means
- that all of the common properties and behaviors that are already known can be placed in an abstract class.
- The specific fly methods will be implemented in each of the specific flying objects.
- Description Interface Abstract Class
- =========================================== ========= ==============
- Can contain abstract methods Yes Yes
- Can contain non-abstract methods No Yes
- Can contain constructors No Yes
- Can be instantiated No No
- Can be extended Yes Yes
- Can be implemented Yes No
- Can contain instance variables No Yes
- Can contain final instance variables No Yes
- Can contain final class variables Yes Yes
- Can contain class variables No Yes
- //////////////////////////////////
- A class can extend another class.
- An abstract class can extend another abstract class.
- A class can extend an abstract class.
- An abstract class can extend a class.
- An interface can extend another interface.
- A class can implement an interface.
- An abstract class can implement an interface.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement