Site Search:

OCPJP Simulation Test 1

<Back to OCPJP





Question: What is the output of the following code?


  1 public abstract class Email {
  2   public String recipient;
  3   abstract final 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 null
C. A compiler error occurs on line 3
D. A compiler error occurs on line 7
E. A compiler error occurs on line 9
F. A RuntimeExeption is thrown
G. None of the above