Topics Index


If you need explanation Read this topic

If you need Answer Take test on this topic

Insert the line of code to show the output as - Show is 420 points.
class Play {
    private int card;
    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) {
        /* Insert Code here*/
    public static void main(String[] args) {
        Play show = new Play(200);
        System.out.println("Show is " + show + " points");

A. p.joker(420);
B. p.changePlay(420);
C. p = new Play(420);
D. Play.joker(420);
E. p = Play.joker(420);
F. None of the above
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.

Object of class Play i.e show is created...
Initially card=200 (Constructor call)
changes the value of card = 1024
changePlay(Play p) gets invoked
Late in System.out.print()
show.toString gets invoked which returns card value 1024 as an integer..
so Answer is F
"Show is 1024 points"

Posted by Kittu Manoj    2014-05-19 08:50:24

Ans is A. reference of Play i.e., show is passed to changePlay and using the reference we can invoke the method joker to change the value of card as 420.

Posted by Nikhil Sulibhavi    2014-05-19 08:50:54

ans a. initially joker havin value invoke the method changeplay() value of the joker changd to 420

Posted by Maheshwari Natarajan    2014-05-19 09:13:48

Answer :F
> Option 1,3 will not  give the desired resulkt
> Option 2 : will not work as we cannot use  it to refer the ChangePlay()
>Option 4 , 5 : will not work as Play is not a STATIC class and we cannot access it by using the class name

Posted by Deepak Kumar Yadav    2014-05-19 11:15:39

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

Posted by Merit Campus    2014-05-20 04:33:43

© meritcampus 2019

All Rights Reserved.

Open In App