Bird
0
0

What will be the output of this code?

medium📝 Predict Output Q4 of 15
Java - Methods and Code Reusability
What will be the output of this code?
public class Test {
  public static int multiply(int x, int y) {
    return x * y;
  }
  public static void main(String[] args) {
    System.out.println(multiply(3, 4));
  }
}
A12
B7
C34
DError: method multiply not found
Step-by-Step Solution
Solution:
  1. Step 1: Understand the multiply method

    It takes two integers and returns their product.
  2. Step 2: Calculate multiply(3, 4)

    3 multiplied by 4 equals 12, which is printed.
  3. Final Answer:

    12 -> Option A
  4. Quick Check:

    multiply(3,4) = 12 [OK]
Quick Trick: Multiply parameters and return result [OK]
Common Mistakes:
  • Adding instead of multiplying
  • Confusing method name
  • Missing static keyword causing error

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Java Quizzes