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

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

    Only class Person {} follows correct syntax.
  3. Final Answer:

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

    Class declaration syntax = class Name {} [OK]
Quick Trick: Use 'class ClassName {}' to declare a class [OK]
Common Mistakes:
  • Placing 'class' after the name
  • Using '=' or ':' in declaration

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Java Quizzes