Site Search:

OCPJP Simulation Test 109

<Back to OCPJP





Question: What is the output of the following program?

  
  1 public abstract class Printer {
  2   public String recipient;
  3   public abstract void print();
  4   public static void main (String[] args) {
  5     Printer p = new HpPrinter();
  6     p.recipient = "xyz@mail.com";
  7     p.print();
  8   }
  9 
 10   static class HpPrinter extends Printer {
 11     public static void print() {
 12       System.out.println("HP printer");
 13 }}}
 14 


Choice:
A. compiler error at line 3
B. compiler error at line 11
C. compiler error at line 5
D. compiler error at line 7
E. HP Printer
F. the program have run time exception
G. it print a blank line
H. it compiles and runs without any output