Computer Applications

Which of the following is a valid method prototype?

  1. public int perform (int a;int b)
  2. public perform (int a, int b)
  3. public int perform (int a, int b)
  4. public perform int (int a, int b)

User Defined Methods

2 Likes

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.

Answered By

1 Like


Related Questions