OO Programming with Java


Exercices

  1. Exploring the Java source code
    a. Unzip the JAVA_PATH/lib/src.zip found in the directory of the jdk.
    b. Take a look at src/java.base/java/lang/Object.java and the method toString to tell how an Object is printed by default ?
  2. Add necessary operations to make it possible the following code:
Person p1, p2; int currentYear;
...
System.out.println( p1.getAge(currentYear)  );
System.out.println( p1.isAdult(currentYear) ); // age >= 18
System.out.println( p1.isOverWeight()       ); // weight/height^2 > 25
System.out.println( p1.isSameAs(p2)         ); // same name

17 - 17