Q:

difference between this and super

this() is used to access one constructor from another with in the 
same class 
while super() is used to
access superclass constructor. Either this() or super() exists it must 
be the first statement in the
constructor.
0
// Java code to illustrate usage of this() 
  
class RR { 
    RR() 
    { 
        this(10); 
        System.out.println("Flow comes back from " +  
                           "RR class's 1 arg const"); 
    } 
  
    RR(int a) 
    { 
        System.out.println("RR class's 1 arg const"); 
    } 
    public static void main(String[] args) 
    { 
        new RR(); 
        System.out.println("Inside Main"); 
    } 
} 
0

New to Communities?

Join the community