Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //45. The getValue() method is overridden in two ways. Which one is correct?
- //I:
- public class Test {
- public static void main(String[] args) {
- A a = new A();
- System.out.println(a.getValue());
- }
- }
- class B {
- public String getValue() {
- return "Any object";
- }
- }
- class A extends B {
- public Object getValue() {
- return "A string";
- }
- }
- //II:
- public class Test {
- public static void main(String[] args) {
- A a = new A();
- System.out.println(a.getValue());
- }
- }
- class B {
- public Object getValue() {
- return "Any object";
- }
- }
- class A extends B {
- public String getValue() {
- return "A string";
- }
- }
- //a. I
- //b. II
- //c. Both I and II
- //d. Neither
- //Key:b
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement