Computer Applications
Which of the following is a valid method prototype?
- public int perform (int a;int b)
- public perform (int a, int b)
- public int perform (int a, int b)
- public perform int (int a, int b)
Answer
public int perform (int a, int b)
Reason — A valid method prototype in Java must specify the access modifier (public), the return type (int), the method name (perform), and the parameter list enclosed in parentheses with parameters separated by commas. The statement public int perform (int a, int b) correctly follows this syntax.
Related Questions
The advantage/s of user-defined methods are/is:
(i) Reusability
(ii) Complexity
(iii) Modularity- Only (i)
- (ii) and (iii)
- Only (iii)
- (i) and (iii)
Parameters which receive the values from the called method are termed as …………… parameters.
- actual
- formal
- reference
- class
Which of the following is the CORRECT statement to invoke the method with the prototype int display(int a, char ch)?
- int m = display('A', 45);
- int m = display( );
- int m = display(A,45);
- int m = display(45,'A');
Which of the following is the CORRECT java statement to convert the word RESPECT to lowercase?
- "RESPECT".tolowercase( );
- "RESPECT".toLowerCase( );
- toLowerCase("RESPECT");
- String.toLowerCase("RESPECT");