Question Index

What will be the output of the following program?

class CarTester
    public static void main(String s[])
        Car car = new Car("Maruti", "Wagon R", 1000, 12.4);

        System.out.println( + "'s " + car.model + " has engine power of " + + "cc.");

class Car
    Car(String company, String model, int cc, double mileage)
    { = company;
        this.model = model; = cc;
        this.mileage = mileage;

    String company;
    String model;
    int cc;
    double mileage;

Maruti's Wagon R has engine power of 1000cc.
null's null has engine power of 0cc.
Compilation Error - since the parameter name passed to the constructor can not be
the same as member variable.
Compilation Error - since there is no default constructor.



Topic: this Keyword In Java

Read this topic
Take test on this topic

Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App