Computer Applications
Which of the following is a valid method prototype in Java?
User Defined Methods
3 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
Design a class to overload a function series( ) as follows:
(a) void series (int x, int n) – To display the sum of the series given below:
x1 + x2 + x3 + ………. xn terms
(b) void series (int p) – To display the following series:
0, 7, 26, 63 ………. p terms
(c) void series () – To display the sum of the series given below:
1/2 + 1/3 + 1/4 + ………. 1/10
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?
Parameters that are passed to the called method during the method call are termed as …………… parameters.
State a difference between call by value and call by reference.