Bird
0
0

Which of the following is the correct syntax to declare a private integer variable named age in a Java class?

easy📝 Syntax Q3 of 15
Java - Encapsulation
Which of the following is the correct syntax to declare a private integer variable named age in a Java class?
Aint private age;
Bprivate integer age;
Cprivate int age;
Dint age private;
Step-by-Step Solution
Solution:
  1. Step 1: Recall Java variable declaration syntax

    Access modifier comes first, then type, then variable name.
  2. Step 2: Check each option

    Only 'private int age;' follows correct order and types.
  3. Final Answer:

    private int age; -> Option C
  4. Quick Check:

    Correct syntax = private int age; [OK]
Quick Trick: Access modifier + type + variable name [OK]
Common Mistakes:
  • Placing private after variable name
  • Using 'integer' instead of 'int'
  • Mixing order of keywords

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Java Quizzes