Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

28. Given the definitions of the Date and I nc Date classes in this chapter, and the following declarations int temp; Da te da te

image text in transcribed
image text in transcribed
28. Given the definitions of the Date and I nc Date classes in this chapter, and the following declarations int temp; Da te da te 1 = new Date( 10, 2, 1989); Dat e da te 2 = new Date(4, 2, 1992); I nc Da te da te 3 = new I nc Date ( 12, 25, 2001); indicate which of the following statements are illegal, and which are legal. Explain your answers. a. te mp = da te 1. get Day;- b.te mp = da te 3. ge t Year(); c. date 1. i ne r eme nt(); d. da te 3. increment (); e. da te 2 - date 1; f. da te 2 = date 3; g. da te 3 = date 2; 40. Assume that date 1 and date 2 are objects of class I nc Date as defined in Section 1.4. What would be the output of the following code? da te 1 = new I nc Date (5, 5, 2000); da te 2 = da tel; System.out.println( da te 1); System.out.println( da te 2): da te 1. increment (); System.out.println( da te 1); System.out.println( da te 2); 1.4 Organizing Classes 23 Cbject +Object(): Object #clonc(): Object +equals(in arg: Object): boolean toString: String etc... myDate Date myDate: Date #year int #month: int #day: int -M NYEAR: int = 1583 year int=1951 month: int6 day:int = 24 +Datet newmonth int, newtayini, ne wYearint) +get Year(): int get Month int +get Day:int lilian): int toString(): String aDate aDate:Ine Date Incute year: int = 2001 month int=1 day: inl = 12 +Inc Date(in newMonth: int. in neway: inl. in newYear:int) +increment) : void Figure 1.4 Extended class diagram showing inheritance sents the day value of the a Date object. During execution, the system changes the int value to a String, concatenates it to the string "Dite day is: and prints it to System out

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Relational Database Technology

Authors: Suad Alagic

1st Edition

354096276X, 978-3540962762

More Books

Students also viewed these Databases questions

Question

Be familiar with the basic ways to manage capacity.

Answered: 1 week ago