16:54 a engineering.purdue.edu engineerin. engineerin. iPad * 69% Ai Annotat Hom
ID: 3606497 • Letter: 1
Question
16:54 a engineering.purdue.edu engineerin. engineerin. iPad * 69% Ai Annotat Home Pag... 30862 (1… enginee.. oop - How erin. Fourth set of questions. Fill in the corresponding line in your answer sheet with what is printed when each line in class Main that has a comment indicating a question is executed. If no method exists that matches the call, answer "None". If more than one method exists that matches the call and javac would be unable to determine which of the matching methods should called, answer "A" (for ambiguous) public class B public BC public void foo(short s, double d) System. out println("sd"); public void foo (short s, B b, double d) f System.out println ("sBd"); public void foo(char c, D d) f System.out println("cD"); public void foo(float f) class Main f System.out.println("f"); public static void main(String args]) f public void foo(double d) t System.out.println("d"); short S 1 public void foo(B b) ( float f = 1.0f; double d- 2.0; B bObj = new B( ); D d0bj new D( ); System.out println("B"); public class D extends B f dobj.foo (s, bObj, f); // Q35 b0bj.foo(s, dObj, f); // Q36 dobj.foo // 937 bobj.foo(s, d); // Q38 bobj.foo(s); // Q39 public DC public void foo(int i, B b, float f) f System.out.println("iBf"); public void foo(int i, B b, double d) System.out printin("iBd"); public void foo(char c, B b, float f) System. out.println("cBf") public void foo(D d) f System.out println("D"); public void foo(short s, D d, float f) f System.out println ("sDf");Explanation / Answer
Please find my answer:
public class Main {
public static void main(String[] args) {
short s = 1;
int i=2;
float f = 1.0f;
double d = 2.0;
B bObj = new B();
D dObj = new D();
dObj.foo(s,bObj,f); // Output : A
bObj.foo(s, dObj, f); // Output: sBd
dObj.foo(); // output : None
bObj.foo(s,d); // Output : sd
bObj.foo(s); // Output: f
}
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.