Advertisement
Guest User

Untitled

a guest
Apr 19th, 2014
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. abstract class hello //abstract class declaration
  2. {
  3. void leo() {}
  4. }
  5.  
  6.  
  7. abstract class test {} //2'nd abstract class
  8.  
  9.  
  10. class dudu { //main class
  11.  
  12. public static void main(String args[])
  13. {
  14. hello d = new test() ; // tried here
  15. }
  16.  
  17. }
  18.  
  19. public abstract class A {
  20. private int a;
  21. public A(int a) {
  22. this.a = a;
  23. }
  24. ...
  25. }
  26.  
  27. public B extends A {
  28. public B() {
  29. super(42);
  30. }
  31. ...
  32. }
  33.  
  34. B b = new B(); // This is an indirect instantiation of A
  35.  
  36. A a = new A(99); // This is a compilation error. You cannot
  37. // instantiate an abstract class directly.
  38.  
  39. abstract class hello //abstract class declaration
  40. {
  41. void leo() {}
  42. }
  43.  
  44. class test extends hello
  45. {
  46. void leo() {} // Custom test's implementation of leo method
  47. }
  48.  
  49. public abstract class Human {
  50. // This class can't be instantiated, there can't be an object called Human
  51. }
  52.  
  53. public Male extends Human {
  54. // This class can be instantiated, getting common features through extension from Human class
  55. }
  56.  
  57. public Female extends Human {
  58. // This class can be instantiated, getting common features through extension from Human class
  59.  
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement