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

Java programming: public class Foo{ Integer x; public Foo(){ x = 1; y = 2; } y =

ID: 3909085 • Letter: J

Question

Java programming:

public class Foo{ Integer x;

public Foo(){ x = 1;

y = 2;

}

y = y1;

public void doSomethingFoo(){ x = 5;

}

public void doSomethingElse(){ doSomethingFoo();

} }

public class Bar extends Foo{ private Integer w;

public Bar(){ w = 4;

}

public void doSomethingFoo(){ x = 6;

}

public void doSomethingBar(){ ...

} }

(1) 13. If the contents of doSomethingBar ) is the following segment: super.doSomethingFoo (); and it gets executed, then: A. xls set to 5, B. x is set to 6, C. compiler error, D. runtime error, E. it depends. (1) 14. What happens when the following code is executed? Foo myVar = new Bar() ; A. AFoo object is created, B. A Bar object is created, C. compiler error, D. none of the above. (1) 15. What happens when the second line (if reached) of the following code is executed? Foo myVar - new Bar ); myVar.doSomethingFoo ); A. x is set to 5, B. x is set to 6, C. compiler error, D. none of the above.

Explanation / Answer

(Ans-)

(13)(A) x is set to 5.

(14)(B) A Bar object is created.

(15)(B) x is set to 6.

(16)(C) compiler error.

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