Menu
Topics Index
...
`

Classes2114


If you need explanation Read this topic

If you need Answer Take test on this topic

Classes2114
What will be the output of the following program?
class Play {
    private int card = 1200;
    public Play(int w) {
        card = w;
    }
    public void joker(int w) {
        card = w;
    }
    public String toString() {
        return Integer.toString(card);
    }
}
public class Playing {
    static void changePlay(Play p) {
    }
    public static void main(String[] args) {
        Play show = new Play(200);
        show.joker(1024);
        changePlay(show);
        System.out.println("Show is " + show + " points");
    }
}

A. Show is 200 points
B. Show is 1200 points
C. Show is 1024 points
D. Some other output
E. Compilation Error or Runtime Error
Topic: Unknown

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

answer is 'D' because in S.o.p we are printng show which holds reference value........

Posted by Sai Teja    2014-01-22 08:36:34


c is the right answer card holds 1024 value, and because of Integer.toString(card) value of card is returned to main as integer

Posted by Akash Kolariya    2014-01-22 09:25:57


Congratulations Akash Sharma. You are this dose winner. We will send you the link using which you can claim your recharge.

Posted by Merit Campus    2014-01-23 04:24:01


But going forward we can not consider Edited comments.

Posted by Merit Campus    2014-01-23 04:30:21


© meritcampus 2019

All Rights Reserved.

Open In App