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

9. The getValue0 method is overridden in two ways. Which one is correct? public

ID: 3714197 • Letter: 9

Question

9. The getValue0 method is overridden in two ways. Which one is correct? public class Testi public static void main(Stringl] args) { A a-new A0; System.out.println(a.getValue0); class B { public String getValue0 { return "Any object"; class A extends B { public Object getValue0 return "A string"; public class Testi public static void main(Stringl] args) { A a-new A0; System.out.println(a.getValue0); class B { public Object getValue0 return "Any object"; class A extends B { public String getValue0i return "A string"; a. c. d. Both I and II Neither

Explanation / Answer

Following is the answer:

Here Option 2 is correct, because class A extends class B and class B returns String and getValue() in class A is also type string, where in option 1 , getValue() return type is object where it returns string.

So, Option 2 is correct.