Bird
0
0

Which of the following is the correct way to declare a class named Book in Java?

easy📝 Syntax Q12 of 15
Java - Object-Oriented Programming Concepts
Which of the following is the correct way to declare a class named Book in Java?
Aclass Book {}
BBook class {}
Cclass = Book {}
Dclass Book() {}
Step-by-Step Solution
Solution:
  1. Step 1: Recall Java class declaration syntax

    In Java, a class is declared using the keyword class followed by the class name and curly braces.
  2. Step 2: Check each option

    class Book {} uses correct syntax: class Book {}. Others have wrong order, symbols, or parentheses.
  3. Final Answer:

    class Book {} -> Option A
  4. Quick Check:

    Java class declaration = class Name {} [OK]
Quick Trick: Remember: class keyword + name + curly braces [OK]
Common Mistakes:
  • Putting parentheses after class name
  • Writing 'Book class' instead of 'class Book'
  • Using '=' sign in class declaration

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Java Quizzes