Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Which group(s) of the following groups of overloaded methods are invalid? Why? a

ID: 3765750 • Letter: W

Question

Which group(s) of the following groups of overloaded methods are invalid? Why?
     
a.
public void run ( double distance, String direction) { ... }
public int run ( String way, double dis) { ... }

b.
public double total(double x, int y, int z) { ... }
public int total(double n1, int n2, int n3) { ... }

c.
public void doResearch( String topic ) { ... }
public void doResearch( String subject, int duration ) { ... }
public String doResearch( String subject ) { ... }
  
d.
public int test(int a, double b, String c) { ... }
public void test(int a, double b, double c) { ... }

Explanation / Answer

public double total(double x, int y, int z) { ... }
public int total(double n1, int n2, int n3) { ... }

There is no difference between these two functions definitions, because the order of parameters and the type for the parameters are same.Because of this two functions call cannont be distinguished

public void doResearch( String topic ) { ... }
public void doResearch( String subject, int duration ) { ... }
public String doResearch( String subject ) { ... }
  

There is no difference between these first and third functions definitions, because the order of parameters and the type for the parameters are same.Because of this two functions call cannont be distinguished

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote