Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
output is
505
505

how ?
what does super(i*j) does

What I have tried:

<pre>class A
{
    public A(int i)
    {
        System.out.println(myMethod(i));
    }
     
    int myMethod(int i)
    {
        return ++i + --i;
    }
}
 
class B extends A
{
    public B(int i, int j)
    {
        super(i*j);
         
        System.out.println(myMethod(i, j));
    }
     
    int myMethod(int i, int j)
    {
        return myMethod(i*j);
    }
}
 
public class MainClass
{
    public static void main(String[] args)
    {
        B b = new B(12, 21);
    }    
}
Posted
Comments
Mohibur Rashid 5-Nov-17 17:03pm    
Super keyword is basic in Java. Have tried reading your text book? Or searching on internet? Or consulting your teacher?
Richard MacCutchan 6-Nov-17 4:46am    
return ++i + --i;
Do not use inline expressions like this, as they may give inconsistent results.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900