What is the result of executing XMLMessage.main?

Given classes defined in two different files:
1. package packageA;
2. public class Message {
3. String getText() { return “text”; }
4. }
and:
1. package packageB;
2. public class XMLMessage extends packageA.Message {
3. String getText() { return “<msg>text</msg>”;}
4. public static void main(String[] args) {

5. System.out.println(new XMLMessage().getText());
6. }
7. }
What is the result of executing XMLMessage.main?

Given classes defined in two different files:
1. package packageA;
2. public class Message {
3. String getText() { return “text”; }
4. }
and:
1. package packageB;
2. public class XMLMessage extends packageA.Message {
3. String getText() { return “<msg>text</msg>”;}
4. public static void main(String[] args) {

5. System.out.println(new XMLMessage().getText());
6. }
7. }
What is the result of executing XMLMessage.main?

A.
Compilation fails because of an error in line 3 of XMLMessage.

B.
An exception is thrown at runtime.

C.
text

D.
<msg>text</msg>

E.
Compilation fails because of an error in line 2 of XMLMessage.



Leave a Reply 0

Your email address will not be published. Required fields are marked *