A

Admin • 833K Points
Coach

Q. What is the output of the following code?

Code:
public static void myMethod(int x) {
System.out.println(x * 2);
}
myMethod(5);
  • (A) 10
  • (B) 5
  • (C) 20
  • (D) There is a syntax error in the code.
  • Correct Answer - Option(A)
  • Views: 24
  • Filed under category Java
  • Hashtags:

Explanation by: Admin

The method myMethod takes an integer parameter and prints out its value multiplied by 2. When the method is called with the argument 5, it prints out 10.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.