Menu
Question Index
...

What will be the output of the following program?

class QuantityOnLiters {
    public float getQuantity() { // LINE 1
        return 1;
    }
}
class QuantityOnGrams extends QuantityOnLiters {
    public int getQuantity() { // LINE 2
        return 100;
    }
}
public class DemoOnQuantity {
    public static void main(String args[]) {
        QuantityOnGrams object = new QuantityOnGrams();
        System.out.println(object);
    }
}


1
100
Compilation Error at LINE 1
Compilation Error at LINE 2
Compilation Error or Runtime Error for some other reason

Doubts

Problems

Topic: Java Class Inheritance

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App