What is difference between "this" and "super" in java?

Here following difference between this and super keyword in java:
  1. "this" refer current class member and Super refer immediate super member.
  2. We can use "this" and "Super" in two ways:
                             1.To refer current class variables, methods:

                                  as this.variable_name; or this.method_name;
                             2. To refer immediate variable and methods as:
                                  Super.variable_name; or Super.method_name;
  3. To refer current class constructor :
                        this();---current class default constructor
                        this(10,5) ----current class argument constructor
   4. To refer immediate super class constructor
                 Super(); Super(10,5) etc...

1 comment :

  1. For more exhaustive list of differences, readers can also refer my notes on this and super in java

    ReplyDelete