Java Programming Fundamentals Practice Test

Casual Mode - Take your time!

1 / 25
Correct
0
Incorrect
0
Score
0%
Multiple Choice

What will be the output of the program?

class Super
{ 
    public int i = 0; 

    public Super(String text) /* Line 4 */
    {
        i = 1; 
    } 
} 

class Sub extends Super
{
    public Sub(String text)
    {
        i = 2; 
    } 

    public static void main(String args[])
    {
        Sub sub = new Sub(Hello); 
        System.out.println(sub.i); 
    } 
}
  1. 0
  2. 1
  3. 2
  4. Compilation fails
Change Mode