Horje
How to call parameterized constructor of a Parent class in Inheritance Code Example
php call parent constructor
<?php
class BaseClass {
   function __construct() {
       print "En el constructor BaseClass\n";
   }
}

class SubClass extends BaseClass {
   function __construct() {
       parent::__construct();
       print "En el constructor SubClass\n";
   }
}
Source: www.php.net
How to call parameterized constructor of a Parent class in Inheritance
/*How to call parameterized constructor  of a Parent class in Inheritance*/
/*Parameterized constructor and Non Parameterized constructor*/
class Parent {
    // Default constructor , not taking args
    Parent() {
        System.out.println("Non Parameterized constructor of Parent");
    }

    // Parameterized constructor, taking args
    Parent(int x) {
        System.out.println("constructor with parameter of Parent " + x);
    }
}

/* Child class which extend from Parent class */
class Child extends Parent {
    // Default constructor
    Child() {
        System.out.println("Non Parameterized constructor of Child");
    }

    Child(int y) {
        System.out.println("constructor with parameter of Child");
    }

    Child(int x, int y) {// One is parameter of Super class int x,
        /*
         * -> * super is keyword that refer to super class and when you passing any
         * parameter
         * that means you are calling to constructor
         */
        super(x);
        System.out.println("2 parameters of Child " + y);
    }
}

public class sample {
    public static void main(String[] args) {

        // Ctreat an obj of child class
        Child child = new Child(10, 20);
    }

}
how to get the parent class using super python
class Foo(Bar):

    def __init__(self, *args, **kwargs):
        # invoke Bar.__init__
        super().__init__(*args, **kwargs)




Java

Related
char default value in java Code Example char default value in java Code Example
HTTP FAILED: java.net.UnknownServiceException: CLEARTEXT communication to ztdev.co.za not permitted by network security policy Code Example HTTP FAILED: java.net.UnknownServiceException: CLEARTEXT communication to ztdev.co.za not permitted by network security policy Code Example
textarea user select disable java swing Code Example textarea user select disable java swing Code Example
spring value # vs $ Code Example spring value # vs $ Code Example
Instant class java Code Example Instant class java Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7