Menu
Question Index
...

What will be the output of the following program? Assume that the inputs are point0(0, 3), point1(4, 0).

public class Distance {
    private final java.awt.Point point0, point1;
    public Distance(int x0, int y0, int x1, int y1) {
        point0 = new java.awt.Point(x0, y0);
        point1 = new java.awt.Point(x1, y1);
    }
    public void printDistance() {
        System.out.println(point0 + " and " + point1 + "\n" + point0.distance(point1));
    }
    public static void main(String[] args) {
        Distance dist = new Distance(intValue(args[0]), intValue(args[1]), intValue(args[2]), intValue(args[3]));
        dist.printDistance();
    }
    private static int intValue(String data) {
        return Integer.parseInt(data);
    }
}


[x=0,y=3] and [x=4,y=0]
0.0
Point[x=0,y=3] and Point[x=4,y=0]
25.0
Point[x=3,y=0] and Point[x=0,y=4]
5.0
(EMPTY)
Some other output
Compilation Error or Runtime Error

Doubts

Problems

Topic: Other Advanced Topics 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