Bird
0
0

Which of the following is the correct way to define a class named Person in Java?

easy📝 Syntax Q12 of 15
Java - Classes and Objects
Which of the following is the correct way to define a class named Person in Java?
APerson class { }
Bclass = Person { }
Cclass Person { }
Ddefine class Person { }
Step-by-Step Solution
Solution:
  1. Step 1: Recall Java class syntax

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

    class Person { } matches the correct syntax: class Person { }. Others have incorrect order or keywords.
  3. Final Answer:

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

    Correct class syntax = class Name { } [OK]
Quick Trick: Use 'class ClassName { }' to define a class [OK]
Common Mistakes:
  • Swapping 'class' and class name
  • Using '=' sign in class definition
  • Using wrong keywords like 'define'

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Java Quizzes