Bird
0
0

Which of the following is the correct syntax to call a method drive() on an object car in Java?

easy📝 Syntax Q3 of 15
Java - Classes and Objects

Which of the following is the correct syntax to call a method drive() on an object car in Java?

Acar.drive();
Bdrive.car();
Ccar->drive();
Dcar:drive();
Step-by-Step Solution
Solution:
  1. Step 1: Recall Java method call syntax

    In Java, methods are called on objects using dot notation: object.method().
  2. Step 2: Check each option

    Only car.drive(); uses correct dot notation. Others use invalid symbols or order.
  3. Final Answer:

    car.drive(); -> Option A
  4. Quick Check:

    Method call syntax = object.method() [OK]
Quick Trick: Use dot (.) to call methods on objects [OK]
Common Mistakes:
  • Using arrow (->) like in C++
  • Reversing object and method order
  • Using colon (:) instead of dot

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Java Quizzes