Java Reference
In-Depth Information
12 sentence(it, "stu", "boo");
13 sentence(it, whom, who);
14 }
15
16 public static void sentence(String she, String who, String whom) {
17 System.out.println(who + " and " + whom + " like " + she);
18 }
19 }
5. What output is produced by the following program?
1 public class MysteryTouch {
2 public static void main(String[] args) {
3 String head = "shoulders";
4 String knees = "toes";
5 String elbow = "head";
6 String eye = "eyes and ears";
7 String ear = "eye";
8
9 touch(ear, elbow);
10 touch(elbow, ear);
11 touch(head, "elbow");
12 touch(eye, eye);
13 touch(knees, "Toes");
14 touch(head, "knees " + knees);
15 }
16
17 public static void touch(String elbow, String ear) {
18 System.out.println("touch your " + elbow + " to your " + ear);
19 }
20 }
6. What output is produced by the following program?
1 public class MysterySoda {
2 public static void main(String[] args) {
3 String soda = "coke";
4 String pop = "pepsi";
5 String coke = "pop";
6 String pepsi = "soda";
7 String say = pop;
8
9 carbonated(coke, soda, pop);
10 carbonated(pop, pepsi, pepsi);
11 carbonated("pop", pop, "koolaid");
12 carbonated(say, "say", pop);
13 }
Search WWH ::




Custom Search