Bird
0
0

Which of the following is the correct way to call a method named displayMessage in Java?

easy📝 Syntax Q12 of 15
Java - Methods and Code Reusability
Which of the following is the correct way to call a method named displayMessage in Java?
Arun displayMessage();
Bcall displayMessage();
CdisplayMessage;
DdisplayMessage();
Step-by-Step Solution
Solution:
  1. Step 1: Recall Java method call syntax

    In Java, you call a method by writing its name followed by parentheses.
  2. Step 2: Check each option

    Only displayMessage(); matches the correct syntax for calling a method.
  3. Final Answer:

    displayMessage(); -> Option D
  4. Quick Check:

    Method call syntax = name() [OK]
Quick Trick: Method call needs parentheses after name [OK]
Common Mistakes:
  • Omitting parentheses when calling methods
  • Adding extra words like 'call' or 'run'
  • Using semicolon without parentheses

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Java Quizzes