... out-of-range for the specified month and year");
25         }
26
27         // check for leap year if month is 2 and day is 29
28         if (month == 2 && day == 29 && !(year % 400 == 0 ||
29               (year % 4 == 0 && year % 100 != 0))) {
30            throw new IllegalArgumentException("day (" + day +
31               ") out-of-range for the specified month and year");
32         }
33
34         this.month = month;
35         this.day = day;
36         this.year = year;
37
38         System.out.printf("Date object constructor for date %s%n", this);
39      }
40
41      // return a String of the form month/day/year
42      public String toString() {
43         return String.format("%d/%d/%d", month, day, year);
44      }
45   }

Date class declaration.

Class Employee

Class Employee (Fig. 8.8) has reference-type instance variables firstName (String), last-Name (String), birthDate ...

Get Java How to Program, Early Objects, 11th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.