Menu
Question Index
...

Choose the incorrect statement about the following program?

class BikeTester
{
    public static void main(String s[])
    {    
        Bike shine = new Bike();
        shine.company = "Hero Honda";
        shine.model = "Shine";
        shine.mileage = 72.5;

        System.out.println(shine.company + "'s " + shine.model + " gives a mileage of " + shine.mileage + "kmpl.");

        Bike pulsar = shine; // LINE A
        pulsar.company = "Bajaj";
        pulsar.model = "Pulsar";
        pulsar.mileage = 55.2;
        pulsar.diskBrakes = true;

        System.out.println(pulsar.company + "'s " + pulsar.model + " gives a mileage of " + pulsar.mileage + "kmpl.");
    }
}

class Bike
{
    String company;
    String model;
    int cc;
    double mileage;
    boolean diskBrakes;
}


This programs creates two bike objects and two bike references.
This programs creates one bike object and two bike references.
All the bike references created in this program point to the same object.
We can copy one reference into another reference like we have done in LINE A.

Doubts

Problems

Topic: Class References And Objects 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