Java Reference
In-Depth Information
21.
What would have been the output of the preceding program if the
third
method had contained the following
statements?
public static void third() {
first();
second();
System.out.println("Inside third method");
}
22.
What would have been the output of the
Strange
program if the
main
method had contained the following
statements? (Use the original version of
third
, not the modified version from the most recent exercise.)
public static void main(String[] args) {
second();
first();
second();
third();
}
23.
What is the output of the following program? (You may wish to draw a structure diagram first.)
1
public class
Confusing {
2
public static void
method2() {
3 method1();
4 System.out.println("I am method 2.");
5 }
6
7
public static void
method3() {
8 method2();
9 System.out.println("I am method 3.");
10 method1();
11 }
12
13
public static void
method1() {
14 System.out.println("I am method 1.");
15 }
16
17
public static void
main(String[] args) {
18 method1();
19 method3();
20 method2();
21 method3();
22 }
23 }
Search WWH ::
Custom Search