Bird
0
0

Which of the following is the correct syntax for a constructor in a class named Book?

easy📝 Syntax Q3 of 15
C Sharp (C#) - Classes and Objects
Which of the following is the correct syntax for a constructor in a class named Book?
Apublic Book() { }
Bpublic void Book() { }
Cvoid Book() { }
Dpublic Book(void) { }
Step-by-Step Solution
Solution:
  1. Step 1: Check constructor syntax rules

    Constructor must have the class name and no return type, with optional access modifier.
  2. Step 2: Identify correct syntax

    public Book() { } matches: public Book() { } is valid.
  3. Final Answer:

    public Book() { } -> Option A
  4. Quick Check:

    Constructor syntax = A [OK]
Quick Trick: Constructor = class name + no return type + parentheses. [OK]
Common Mistakes:
MISTAKES
  • Adding void return type to constructor
  • Using return type void or any other type
  • Incorrect parameter list syntax

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Sharp (C#) Quizzes