Computer Applications
What is the type of error, if any, when two methods have the same method signature?
- Runtime error
- Logical error
- Syntax error
- No error
Answer
Syntax error
Reason — If two methods in the same class have the same method signature (i.e., the same method name and the same parameters), the Java compiler will report a syntax error. This is because Java does not allow duplicate method signatures in the same class as it cannot differentiate which method to call.
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 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)
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');