1  /**
  2     This program demonstrates conversions between class and 
  3     interface types.
  4  */
  5  public class ConversionTester
  6  {
  7     public static Measurable larger(Measurable obj1, Measurable obj2)
  8     {
  9        if (obj1.getMeasure() > obj2.getMeasure()) 
 10        { 
 11           return obj1; 
 12        }
 13        else 
 14        { 
 15           return obj2; 
 16        }
 17     }
 18  
 19     public static void main(String[] args)
 20     {
 21        Country uruguay = new Country("Uruguay", 176220);
 22        Country thailand = new Country("Thailand", 513120);
 23        Measurable max = larger(uruguay, thailand);
 24        Country maxCountry = (Country) max;
 25        String name = maxCountry.getName();
 26        System.out.println("Country with larger area: " + name);
 27        System.out.println("Expected: Thailand");
 28     }
 29  }