Which group(s) of the following groups of overloaded methods are invalid? Why? a
ID: 3765758 • 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
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.