Bird
0
0

Which of the following is the correct syntax to declare a class named Person in Java?

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

    Java classes are declared with the keyword 'class' followed by the class name and braces.
  2. Step 2: Check each option

    class Person {} matches correct syntax; others have syntax errors like parentheses or wrong order.
  3. Final Answer:

    class Person {} -> Option C
  4. Quick Check:

    Class syntax = class Name {} [OK]
Quick Trick: Use 'class ClassName {}' to declare a class [OK]
Common Mistakes:
  • Adding parentheses after class name
  • Using wrong keyword order
  • Using colon instead of braces

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Java Quizzes