PRASHNIKAप्रश्निका
‹ Back to the paper

Which of the following is a valid prototype of the non-parameterised constructor for the class Book?

Computer Science20251 markMCQ
  • apublic class Book {}
  • bBook(void)
  • cpublic Book( )
  • dpublic Book(void)

Answer

Answer

AI

Correct 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.
Objects

From ISC Computer Science - Competency Focused Practice Questions (CISCE, August 2024), question 14.