Menu
Question Index
...

What will be the output of the following program?

public class Price {
    public void doIt(int i, HtcMobile p) {
        i = 10000;
        p.number = 1;
    }
    public static void main(String args[]) {
        int x = 2000;
        HtcMobile p = new HtcMobile();
        new Price().doIt(x, p);
        System.out.println("Price: " + x + ", Mobile Count: " + p.number);
    }
}
class HtcMobile {
    public int number;
}


Price: 2000, Mobile Count: 1
Price: 10000, Mobile Count: 1
Price: 2000, Mobile Count: 0
Price: 10000, Mobile Count: 0
Some other output
Compilation Error or Runtime Error

Doubts

Problems

Topic: Behavior Of Java Classes Using Methods

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App