Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a method called makeItNewYears that could be added to the class DateFirstTry in Display 4.1. The method makeItNewYears has no parameters and sets the

Write a method called makeItNewYears that could be added to the class DateFirstTry in Display 4.1. The method makeItNewYears has no parameters and sets the month instance variable to "January" and the day instance variable to 1. It does not change the year instance variable.

Display 4.1:

image text in transcribed

Display 4.1 A Simple Class This class definition goes in a DatePirstTry-java file named 1 public class DatePirstTry public String month public int day: public int year: //a four digit number Later in this chapter, we will see that these three public modifiers should be replaced withprivate. public void writeOutput ) System-out.printIn(month + + day + ". " + year) ; 10 1 publie class DateFirstTryDemoThis class definition (program) goes in a file named DatePirstTryDemo java public static void main (String[] args) DateFirstTry datel, date2; datelnew DateFirstTry) date2new DateFirstTry ) datel.month December"; datel.day31 datel.year- 2012; System. out . printin ( date 1 : " ) ; datel.writeOutput ) 10 14 15 16 17 18 19 date2.monthJuly" date2.day4 date2.year 1776; System. out . print In ( "date2 : " ) ; date2.writeOutput ) Sample Dialogue datel: December 31, 2012 date2: July 4, 1776

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions