Bird
0
0

Which of the following is the correct syntax for a class Car implementing two interfaces Engine and Wheels?

easy📝 Syntax Q12 of 15
Java - Interfaces
Which of the following is the correct syntax for a class Car implementing two interfaces Engine and Wheels?
Apublic class Car implements Engine & Wheels {}
Bpublic class Car extends Engine, Wheels {}
Cpublic class Car implements Engine, Wheels {}
Dpublic class Car extends Engine implements Wheels {}
Step-by-Step Solution
Solution:
  1. Step 1: Recall Java syntax for implementing multiple interfaces

    Java uses the keyword implements followed by a comma-separated list of interfaces.
  2. Step 2: Check each option's syntax

    public class Car implements Engine, Wheels {} correctly uses implements Engine, Wheels. Options B and D incorrectly use extends for interfaces or mix keywords wrongly. public class Car implements Engine & Wheels {} uses an invalid '&' symbol.
  3. Final Answer:

    public class Car implements Engine, Wheels {} -> Option C
  4. Quick Check:

    Multiple interfaces use comma with implements = A [OK]
Quick Trick: Use 'implements' with commas for multiple interfaces [OK]
Common Mistakes:
  • Using extends instead of implements for interfaces
  • Using '&' instead of commas
  • Mixing extends and implements incorrectly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Java Quizzes