Menu
Question Index
...

What will be the output of the following program?

public class Mystery {
    public static void main(String[] args) {
        String hear = "bad";
        String song = "good";
        String good = "hear";
        String walk = "talk";
        String talk = "feel";
        String feel = "walk";
        print(feel, song, feel);
        print(good, hear, song);
        print(talk, "song", feel);
        print("claim", talk, walk);
    }
    public static void print(String hear, String good, String song) {
        System.out.println("to " + hear + " the " + song + " is " + good);
    }
}


to walk the walk is good
to hear the good is bad
to feel the walk is song
to claim the talk is feel
to hear the good is bad
to walk the walk is good
to feel the song is walk
to claim the talk is feel
to walk the good is walk
to feel the walk is song
to hear the good is bad
to claim the feel is talk
to bad the good is hear
to hear the good is hear
to feel the song is walk
to claim the good is talk
Compilation Error or Runtime Error

Doubts

Problems

Topic: Java Methods - Parameter Passing And Scope

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App