Question: Consider the following class definitions. publ ic class A { publ ic St r ing message ( int i ) { return A
Consider the following class definitions.
publ ic class A
publ ic St r ing message int i
return A i ;
publ ic class B extends A
publ ic St r ing message int i
return B i ;
The following code segment appears in a class other than A or B
A obj new B ; Line
B obj new B ; Line
System.out pr int lnobjmessage ; Line
System.out pr int lnobjmessage ; Line
Which of the following best explains the difference, if any, in the behavior of the code segment that will result
from removing the message method from class A
A The statement in line will cause a compiler error because the message method for obj cannot
be found.
B The statement in line will cause a compiler error because the message method for obj cannot
be found.
C As a result of the method call in line the message method in class B will be executed instead of
the message method in class A
D As a result of the method call in line the message method in class B will be executed instead of
the message method in class A
E The behavior of the code segment will remain unchanged
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
