<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">/**
 * This program demonstrates the use of super in a constructor
 * to call a constructor of the superclass, and also that superclass
 * constructors are called automatically.  Try removing the "super(t)"
 * from the first constructor of Bar2 and see what happens.
 */

class Test2 {
   public static void main(String[] args) {
      System.out.println(new Bar2().lunch);
      System.out.println(new Bar2("ham").lunch);
   }  
}

class Foo2 {
   String lunch;
   
   Foo2() {
      lunch = "turkey";
   }
   
   Foo2(String s) {
      lunch = s;
   }
}

class Bar2 extends Foo2 {
   Bar2(String t) {
      super(t);
      lunch += " sandwich";
   }
   
   Bar2() {
      lunch += " sandwich";
   }
}</pre></body></html>