Menu
Question Index
...

What will be the output of the following program?

class FourWheeler
{
    public static void main(String[] args)
    {
        new Car(0);
    }
}

class Vehicle
{
    int i;
    int j;

    Vehicle(int i)
    {
        this.i = i;
        j = i;
    }

    Vehicle(int i, int j)
    {
        this.i = i;
        this.j = j;
    }
}

class Bus extends Vehicle
{
    double j;

    Bus(double j)
    {
        this.j = j;
    }
}

class Car extends Vehicle
{
    Car(int i)
    {
        super(i);
        System.out.print("Executed Successfully");
    }
}


Executed Successfully
Compilation Error because the class Vehicle does not
have a default constructor
Compilation Error for some other reason
Runtime Error

Doubts

Problems

Topic: Inheritance And Constructors In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App