‹ Back to the paper
Which of the following is a valid prototype of the non-parameterised constructor for the class Book?
- apublic class Book {}
- bBook(void)
- cpublic Book( )
- dpublic Book(void)
Answer
Answer
AICorrect option: c
Answer: (c) public Book( ).
A non-parameterised (default) constructor has the same name as the class, no parameters and public access, exactly as public Book( ). Book(void) and public Book(void) are not valid Java syntax, and 'public class Book {}' is a class declaration, not a constructor.
From ISC Computer Science - Competency Focused Practice Questions (CISCE, August 2024), question 14.