KnowledgeBoat Logo
|

Computer Applications

In the following method prototype to accept a character, an integer and return YES or NO, fill in the blank to complete the method prototype.

public ............... someMethod(char ch, int n)

  1. boolean
  2. String
  3. int
  4. double

User Defined Methods

3 Likes

Answer

String

Reason — The method is required to return "YES" or "NO", which are textual values. In Java, such values are represented using the String data type. Hence, the return type of the method should be String, not boolean, int, or double.

The complete method prototype:

public String someMethod(char ch, int n)

Answered By

2 Likes


Related Questions