Java Reference
In-Depth Information
7 System.out.println("number = " + number);
8 }
9
10 public static void halfTheFun( int number) {
11 number = number / 2;
12 for ( int count = 1; count <= number; count++) {
13 System.out.print(count + " ");
14 }
15 System.out.println();
16 }
17 }
3. What is the output of the following program?
1 public class MysteryNumbers {
2 public static void main(String[] args) {
3 String one = "two";
4 String two = "three";
5 String three = "1";
6 int number = 20;
7
8 sentence(one, two, 3);
9 sentence(two, three, 14);
10 sentence(three, three, number + 1);
11 sentence(three, two, 1);
12 sentence("eight", three, number / 2);
13 }
14
15 public static void sentence(String three, String one, int number) {
16 System.out.println(one + " times " + three + " = " + (number * 2));
17 }
18 }
4. What output is produced by the following program?
1 public class MysteryWho {
2 public static void main(String[] args) {
3 String whom = "her";
4 String who = "him";
5 String it = "who";
6 String he = "it";
7 String she = "whom";
8
9 sentence(he, she, it);
10 sentence(she, he, who);
11 sentence(who, she, who);
Search WWH ::




Custom Search