Java Nested Method Definition
What error prevents this code from compiling?
public class Outer {
public static void main(String[] args) {
System.out.println("Hello");
void innerMethod() {
System.out.println("Inner");
}
}
}
A
The System.out.println statement in main is incorrect.
B
The innerMethod is missing a return type.
C
Defining a method inside another method is not allowed in Java.
D
There is a missing semicolon after the innerMethod definition.
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | kaisuki | 1 | 1 | 0m 00s | 100 |
| #2 | gtsak31 | 1 | 1 | 2m 57s | -77 |
| #3 | bommasam000 | 1 | 1 | 4m 22s | -162 |
| #4 | y.seong2027 | 1 | 2 | 5m 44s | -254 |
Items per page:
10
1 – 4 of 4
APFIVE