KnowledgeBoat Logo

Computer Applications

Method prototype for the method compute which accepts two integer arguments and returns true/false.

  1. void compute (int a, int b)
  2. boolean compute (int a, int b)
  3. Boolean compute (int a,b)
  4. int compute (int a, int b)

User Defined Methods

ICSE Sp 2025

1 Like

Answer

boolean compute (int a, int b)

Reason — Let's analyse the given options:

  1. void compute (int a, int b) — Incorrect because void means the method does not return any value, but the question requires the method to return true/false.

  2. boolean compute (int a, int b) — Correct because it returns a boolean value (true or false) and accepts two integer arguments.

  3. Boolean compute (int a, b) — Incorrect due to syntax error (int b is not fully declared). Also, Boolean is a wrapper class, not a primitive boolean.

  4. int compute (int a, int b) — Incorrect because the return type is int, not boolean.

Answered By

3 Likes


Related Questions