Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

java constructor chaining

class Base {
  
    int number;
 
    // Constructure of Base class
    Base(int number) {
      
        this.number = number;
    }
}
 
class Derived extends Base {

    // Constructure of Derived class
    Derived(int number) {
      
    	// calls constructure of Base class
        super(number);
    }
 
    public static void main(String args[]) {
      
        // calls constructure of Derived class
        Derived obj = new Derived(99);
    }
}
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #java #constructor #chaining
ADD COMMENT
Topic
Name
6+9 =