Java Reference
In-Depth Information
24.
What would have been the output of the preceding program if the
method3
method had contained the following
statements?
public static void method3() {
method1();
method2();
System.out.println("I am method 3.");
}
25.
What would have been the output of the
Confusing
program if the
main
method had contained the following
statements? (Use the original version of
method3
, not the modified version from the most recent exercise.)
public static void main(String[] args) {
method2();
method1();
method3();
method2();
}
26.
The following program contains at least 10 syntax errors. What are they?
1
public class
LotsOf Errors {
2
public static
main(String args) {
3 System.println(Hello, world!);
4 message()
5 }
6
7
public static void
message {
8 System.out println("This program surely cannot ";
9 System.out.println("have any "errors" in it");
10 }
27.
Consider the following program, saved into a file named
Example.java
:
1
public class
Example {
2
public static void
displayRule() {
3 System.out.println("The first rule ");
4 System.out.println("of Java Club is,");
5 System.out.println();
6 System.out.println("you do not talk about Java Club.");
7 }
8
9
public static void
main(String[] args) {
10 System.out.println("The rules of Java Club.");
11 displayRule();
12 displayRule();
13 }
14 }
Search WWH ::
Custom Search