Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- abstract class hello //abstract class declaration
- {
- void leo() {}
- }
- abstract class test {} //2'nd abstract class
- class dudu { //main class
- public static void main(String args[])
- {
- hello d = new test() ; // tried here
- }
- }
- public abstract class A {
- private int a;
- public A(int a) {
- this.a = a;
- }
- ...
- }
- public B extends A {
- public B() {
- super(42);
- }
- ...
- }
- B b = new B(); // This is an indirect instantiation of A
- A a = new A(99); // This is a compilation error. You cannot
- // instantiate an abstract class directly.
- abstract class hello //abstract class declaration
- {
- void leo() {}
- }
- class test extends hello
- {
- void leo() {} // Custom test's implementation of leo method
- }
- public abstract class Human {
- // This class can't be instantiated, there can't be an object called Human
- }
- public Male extends Human {
- // This class can be instantiated, getting common features through extension from Human class
- }
- public Female extends Human {
- // This class can be instantiated, getting common features through extension from Human class
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement