Menu
Question Index
...

What will be the output of the following program.

class BikeTester
{
    public static void main(String s[])
    {
        Bike bike;
        bike.company = "Hero Honda";
        bike.model = "Shine";
        bike.cc = 125;
        bike.mileage = 72.5;
        bike.diskBrakes = false;

        System.out.println(bike.company + "'s " + bike.model + " gives a mileage of " + bike.mileage + "kmpl.");
    }
}
class Bike
{
    String company;
    String model;
    int cc;
    double mileage;
    boolean diskBrakes;
}


Hero Honda's Shine gives a mileage of 72.5kmpl.
Compilation error - since Bike class has two Strings - company and model.
Runtime Error - NullPointerException since the bike object is not created.
Compilation error - since Bike class does not have a constructor.

Doubts

Problems

Topic: Member Variable 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