Computer Applications
Method prototype for the method compute which accepts two integer arguments and returns true/false.
- void compute (int a, int b)
- boolean compute (int a, int b)
- Boolean compute (int a,b)
- int compute (int a, int b)
User Defined Methods
ICSE Sp 2025
9 Likes
Answer
boolean compute (int a, int b)
Reason — Let's analyse the given options:
void compute (int a, int b)— Incorrect becausevoidmeans the method does not return any value, but the question requires the method to returntrue/false.boolean compute (int a, int b)— Correct because it returns abooleanvalue (trueorfalse) and accepts two integer arguments.Boolean compute (int a, b)— Incorrect due to syntax error (int bis not fully declared). Also,Booleanis a wrapper class, not a primitiveboolean.int compute (int a, int b)— Incorrect because the return type isint, notboolean.
Answered By
3 Likes
Related Questions
To execute a loop 10 times, which of the following is correct?
- for (int i=11;i<=30;i+=2)
- for (int i=11;i<=30;i+=3)
- for (int i=11;i<20;i++)
- for (int i=11;i<=21;i++)
A single dimensional array has 50 elements, which of the following is the correct statement to initialize the last element to 100.
- x[51]=100
- x[48]=100
- x[49]=100
- x[50]=100
The statement that brings the control back to the calling method is:
- break
- System.exit(0)
- continue
- return
The default value of a boolean variable is:
- False
- 0
- false
- True