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.
πŸ’¬ Discuss
βœ… Correct Answer: (A) 10
Explanation: 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.
Explanation by: Deepak Sahoo
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.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
218
Total Visits
πŸ“½οΈ
3 y ago
Published
πŸŽ–οΈ
Deepak Sahoo
Publisher
πŸ“ˆ
96%
Success Rate