Are you taking CLEP classes? Try clep.ai
| preferred AP College board partner for AP classes
AP Computer Science A/Unit 10: Recursion
Start Practice TestPractice Test
About Exam
medium Solved by 3 students

Illegal Recursive Constructor Invocation

Mark
< 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 main method instantiates RecursiveConstructor incorrectly.

B

The class is missing a proper base case for recursion.

C

The constructor calls itself recursively using ‘this()’, which is not allowed and causes a compilation error.

D

The recursive call in the constructor lacks a termination condition.

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

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Total 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|