Create a class called Date that includes three pieces of information as instance variables a month (type int), a day (type int) and a year (type int). Your class should have a constructor that initializes the three instance variables and assumes that the values provided are correct. Provide a set and a get method for each instance variable. Provide a method displayDate that displays the month, day and year separated by forward slashes (/). Write a test application named DateTest that demonstrates class Date's capabilities.


Updated: Nov. 27, 2020 — Training Time: 2 minutes
Overseen by: Archangel Macsika
Topic:Date Time - Java Programming

Difficulty: Advance.

Companies who previously asked this: -.

Objective: Create a class called Date that includes three pieces of information as instance variables a month (type int), a day (type int) and a year (type int). Your class should have a constructor that initializes the three instance variables and assumes that the values provided are correct. Provide a setter and a getter method for each instance variable. Provide a method displayDate that displays the month, day and year separated by forward slashes (/).
Write a test application named DateTest that demonstrates class Date's capabilities.

Input: Three different values to serve as the day, month, and year.

Expected Output: Displays the month, day and year separated by forward slashes based on the user input.

Sikademy Solution

Date.java

DateTest.java

Was this training resource helpful?