Site Search:

OCPJP Simulation Test 5

<Back to OCPJP





Question: What is the output of the following program?


  1 public abstract class Message {
  2   String recipient;
  3   void sendMessage(){};
  4   public static void main(String args[]) {
  5     Message email = new XyzMessage();
  6     email.recipient = "John@xyznetwork.com";
  7     email.sendMessage();
  8   }
  9   static class XyzMessage extends Message {
 10     public final void sendMessage()  {
 11       System.out.println("Message is sent to " + recipient);
 12     }}}


Choice:
A. Message is sent to John@xyznetwork.com
B. Message is sent to null
C. Compile error at line 1
D. Compile error at line 7
E. Compile error at line 9
F. Compile error at line 10
G. Compile error at line 11