| preferred AP College board partner for AP classes
AP Computer Science A/Unit 10: Recursion
Start Practice TestPractice Test
About Exam
medium Solved by 4 students
Illegal Recursive Constructor Invocation
< Prev
Next >

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.

Hint
Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer
Report Question

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Time
Score
#1ravi.palepu11 0m 30s 70
#2michael.matveyev01 1m 34s -104
#3singhris00013 5m 14s -234
Items per page:
10
1 – 3 of 3

AI Tutor

How can I help?

APFIVE © 2020.
Email: apfive@apfive.org|Privacy Policy