<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 commenting out the "super(t)" from the first
 * constructor of Bar and see what happens.
 */

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

class Foo {
   String lunch;

   Foo() {
      lunch = "turkey";
   }

   Foo(String s) {
      lunch = s;
   }
}

class Bar extends Foo {
   Bar(String t) {
      super(t);
      lunch += " sandwich";
   }

   Bar() {
      lunch += " sandwich";
   }
}</pre></body></html>