Site Search:

OCPJP Simulation Test 6

<Back to OCPJP





Question: What is the output of the following program?


  1 public abstract class Message {
  2   private static 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
B. Message is sent to John@xyznetwork.com
C. Message is sent to null
D. A compile error at line 1
E. A compile error at line 2
F. A compile error at line 9
G. A compile error at line 11
H. A compile error at other line