Menu
Question Index
...

What will be the output of the following program?

class Point {
    final int x, y;
    final String name;
    Point(int X, int Y) {
        x = X;
        y = Y;
        name = makeN();
    }
    String makeN() {
        return "[" + x + "," + y + "]";
    }
    public String toString() {
        return name;
    }
}
public class Point2 extends Point {
    final String c;
    Point2(int x, int y, String C) {
        super(x, y);
        c = C;
    }
    String makeN() {
        return super.makeN() + ":" + c;
    }
    public static void main(String... a) {
        System.out.println(new Point2(1, 3, "Blue"));
    }
}


[1,3]:Blue
[2,4]:Blue
[3,1]:Blue
Some other output
Compilation Error or Runtime Error

Doubts

Problems

Topic: final Keyword 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