Advertisement
Guest User

Untitled

a guest
Apr 20th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. Abstract classes are used to define a class that will be used only to build new classes.
  2. No objects will ever be instantiated from an abstract class. Abstract classes are used to create hie-
  3. rarchies of classes.
  4.  
  5. Any sub class that extends a super abstract class must implement all methods defined as abstract in the
  6. super class unless the extending class is abstract class.
  7.  
  8. Abstract classes are great when you know quite a bit about an Object, but not everything.
  9. For instance, say you are writing a program to simulate flying objects and you know that
  10. all of the objects will have width, height, and speed, but you do not know how each one will fly.
  11. The fly properties and behavior will differ for each type of flying object which means
  12. that all of the common properties and behaviors that are already known can be placed in an abstract class.
  13. The specific fly methods will be implemented in each of the specific flying objects.
  14.  
  15.  
  16. Description Interface Abstract Class
  17. =========================================== ========= ==============
  18. Can contain abstract methods Yes Yes
  19. Can contain non-abstract methods No Yes
  20. Can contain constructors No Yes
  21. Can be instantiated No No
  22. Can be extended Yes Yes
  23. Can be implemented Yes No
  24.  
  25. Can contain instance variables No Yes
  26. Can contain final instance variables No Yes
  27. Can contain final class variables Yes Yes
  28. Can contain class variables No Yes
  29. //////////////////////////////////
  30.  
  31. A class can extend another class.
  32. An abstract class can extend another abstract class.
  33. A class can extend an abstract class.
  34. An abstract class can extend a class.
  35. An interface can extend another interface.
  36.  
  37. A class can implement an interface.
  38. An abstract class can implement an interface.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement