Computer Applications
Which of the following is a valid method prototype in Java?
User Defined Methods
12 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
3 Likes
Related Questions
Consider the following program segment and answer the questions below:
class calculate { int a; double b; calculate() { a=0; b=0.0; } calculate(int x, double y) { a=x; b=y; } void sum() { System.out.println(a*b); }}Name the type of constructors used in the above program segment?
Invoking a method by passing the objects of a class is termed as:
- Call by reference
- Call by value
- Call by method
- Call by constructor