Bird
0
0

Which of the following is the correct way to create a new object in Java?

easy📝 Syntax Q12 of 15
Java - Memory Management Basics
Which of the following is the correct way to create a new object in Java?
AMyClass obj = MyClass();
BMyClass obj = create MyClass();
CMyClass obj = new MyClass();
DMyClass obj = new MyClass;
Step-by-Step Solution
Solution:
  1. Step 1: Recall Java object creation syntax

    Objects are created using the new keyword followed by the constructor call with parentheses.
  2. Step 2: Check each option's syntax

    MyClass obj = new MyClass(); uses correct syntax: new MyClass();. Options A, C, and D are incorrect due to missing new, wrong keywords, or missing parentheses.
  3. Final Answer:

    MyClass obj = new MyClass(); -> Option C
  4. Quick Check:

    Use new ClassName() to create objects [OK]
Quick Trick: Use 'new' keyword plus parentheses to create objects [OK]
Common Mistakes:
  • Omitting the 'new' keyword
  • Forgetting parentheses after class name
  • Using incorrect keywords like 'create'

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Java Quizzes