Illegal Recursive Constructor Invocation
Why will the following code segment fail to compile?
public class RecursiveConstructor {
public RecursiveConstructor() {
this();
}
public static void main(String[] args) {
new RecursiveConstructor();
}
}
A
The recursive call in the constructor lacks a termination condition.
B
The constructor calls itself recursively using ‘this()’, which is not allowed and causes a compilation error.
C
The main method instantiates RecursiveConstructor incorrectly.
D
The class is missing a proper base case for recursion.
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | ravi.palepu | 1 | 1 | 0m 30s | 70 |
| #2 | michael.matveyev | 0 | 1 | 1m 34s | -104 |
| #3 | singhris000 | 1 | 3 | 5m 14s | -234 |
Items per page:
10
1 – 3 of 3
APFIVE