Java Inheritance - calling superclass method

前端 未结 5 1252
遥遥无期
遥遥无期 2020-11-27 18:15

Lets suppose I have the following two classes

public class alpha {

    public alpha(){
        //some logic
    }

    public void alphaMethod1(){
        /         


        
5条回答
  •  离开以前
    2020-11-27 18:44

    Whenever you create child class object then that object has all the features of parent class. Here Super() is the facilty for accession parent.

    If you write super() at that time parents's default constructor is called. same if you write super.

    this keyword refers the current object same as super key word facilty for accessing parents.

提交回复
热议问题