Menu
Question Index
...

What will be the output of the following program?

import java.awt.*;
public class Tricky {
    public static void main(String[] args) {
        int a = 7;
        int b = 9;
        Point p1 = new Point(2, 2);
        Point p2 = new Point(2, 2);
        getPrint(a, p1);
        System.out.println(a + " " + b + " " + p1.x + " " + p2.x);
        getPrint(b, p2);
        System.out.println(a + " " + b + " " + p1.x + " " + p2.x);
    }
    public static void getPrint(int a, Point p1) {
        a = a + a;
        p1.x = a;
        System.out.print(a + " " + p1.x + " - ");
    }
}


14 14 - 7 9 14 2
14 14 - 7 9 14 2
14 14 - 7 9 14 2
18 18 - 7 9 14 18
14 14 - 7 9 14 2
18 18 - 7 9 14 2
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