Computer Applications
Which of the following is a valid method prototype in Java?
User Defined Methods
2 Likes
Answer
public double calculate(double x, double y)
Reason — The syntax of a method prototype is:
<access-specifier> <return-type> <method-name> (<parameter-list>)
Only public double calculate(double x, double y)
follows this syntax.
Answered By
1 Like
Related Questions
Which OOP principle implements method overloading?
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)
Define a class to overload the method display() as follows:
void display(): To print the following format using nested loop.
1 2 1 2 1
1 2 1 2 1
1 2 1 2 1void display (int n, int m) : To print the quotient of the division of m and n if m is greater than n otherwise print the sum of twice n and thrice m.
double display (double a, double b, double c) — to print the value of z where
State a difference between call by value and call by reference.