Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Java write a class definition for Date, an object type that contains three private field integers: year, month, and day. This class should provide

In Java write a class definition for Date, an object type that contains three private field integers: year, month, and day. This class should provide two constructors. The first should take no parameters and initialize a default date (12/30/2020). The second should take parameters named day, month and year, and use them to initialize the instance variables. Write getters and setters for year, month, and day (getYear, setYear, getMonth, setMonth, getDay, setDay). Implement the toString and equals methods. The toString method should output the date in American date format (e.g. year = 2020, month = 12, day = 10 should output 12/10/2020).

Hint: To add a class to a file with a different name, you can remove public from your new classs definition.

For example:

public class A6 { }

class Date

{

// Dates implementation

}

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_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions

Question

Understand why customers are loyal to a particular service firm.

Answered: 1 week ago