Multiple choice java

Given the following class definition, which of the following methods could be legally placed after the comment //Here public class Rid{ public void amethod(int i, String s){} //Here }

  1. public void amethod(int s, String i){}

  2. public void Amethod(int i, String s) {}

  3. public void amethod(int i, String mystring){}

  4. None of the above

  5. public int amethod(int i, String s){}

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The question asks which method can be legally placed in the class. Option A changes only parameter names (s, i), which is invalid overloading (same signature). Option C changes a parameter name (mystring), same signature. Option E changes the return type only, which is invalid. Option B changes the method name to 'Amethod' (case sensitivity), creating a valid overloaded method.