Site Search:

OCPJP Simulation Test 7

<Back to OCPJP





Question: What is the output of the following program?


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


Choice:
A. Package is sent to
B. Package is sent to null
C. Package is sent to John Brown
D. Compilation error at line 2
E. Compilation error at line 5
F. Compilation error at line 9
G. Compilation error at line 10
H. Compilation error at line 11