Question Index

What will be the output of the following program.

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

        System.out.println( + "'s " + bike.model + " has " + + "cc power.");

class Bike
    Bike(String companyParam, String modelParam, int ccParam)
        company = companyParam;
        model = modelParam;
        cc = ccParam;


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

Compilation Error - since we can not have multiple constructors in a class.
Compilation Error - since we can not define a constructor with no parameters.
Every constructor should have at least one parameter.
Hero Honda's Shine has 125cc power.
Compilation Error - since the default constructor has to be
defined above the other constructors.



Topic: Class With Multiple Constructors In Java

Read this topic
Take test on this topic

Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App