Site Search:

OCPJP Simulation Test 4

<Back to OCPJP





Question: What is the output of the following program?


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


Choice:
A. Email is sent to John@xyznetwork.com
B. Email is sent to
C. Email is sent to null
D. Compilation error at line 2
E. Compilation error at line 3
F. Compilation error at line 5
G. Compilation error at line 9
H. Compilation error at line 11