This website is preserved for historical and scholarly reference and is no longer actively maintained.
QUIZ 5
September 1, 1997
new Time (a, b, c, d, e, f)
creates an object of class Time, where a is the year, b is the month, c is the day, d is the hours, e is the minutes, and f is the seconds. The methods for class Time are
t.addSeconds ( n )
t.secondsFrom (t2)
t.getSeconds ( )
t.getMinutes ( )
t.getHours ( )
t.getDay ( )
t.getMonth ( )
t.getYear ( )
#1. What value of year is stored in myDate by
Time myDate = new Time ( );
#2. Write a Java statement that defines a variable of class Time named BDay and stores the date July 4, 1776, in BDay.
#3. Suppose you want to add the number of seconds in 1 day to an object of the class Time. You will want to define a constant, perhaps called oneDay. Complete the declaration and initialization of oneDay.
static public final double oneDay =
#4. Write a Java statement that will add one day to myDate defined in question #1 above.
#5. What will be printed by
System.out.println(BDay.getYear( ) + " " + BDay.getMonth( ) + " " + BDay.getDay( ) );