Absolute Java (6th Edition)
Absolute Java (6th Edition)
6th Edition
ISBN: 9780134041674
Author: Walter Savitch, Kenrick Mock
Publisher: PEARSON
bartleby

Concept explainers

bartleby

Videos

Textbook Question
Book Icon
Chapter 4, Problem 1STE

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.

Expert Solution & Answer
Check Mark
Program Plan Intro

Question reference: The method, makeItNewYears, which having the no parameter, also sets the instance variable named month to “January� and set the current day to 1.

Program Description Answer

Method Explanation:

The definition of the method, makeItNewYears, sets the value of month and day.

Month and day are the instance variables of class, DateFirstTry.

The method sets the month variable to January, the day variable to 1.

Explanation of Solution

Method:

//Method definition

public void makeItNewYears()

{

            month=�January�; //sets the month variable

           day=1; //sets the day variable

}

Want to see more full solutions like this?

Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
03:57
Students have asked these similar questions
1A. Create a Die class with one integer instance variable called sideUp. Give it a constructor and a getSideUp() method that returns the value of sideUp and a void roll() method that changes sideUp to a random value from 1 to 6. [Note: To generate a random integer between 1 and 6, use Math.random() method] Then create a DieDemo class with a main method that creates two Die objects, rolls them, and then prints the sum of the two sides up.
Modify the student class presented in this chapter as follows. Each student object should also contain the scores for three tests. Provide a constructor that sets all instance values based on parameter values. Overload the constructor such that each test score is assumed to be initially zero. Provide a method called setTestScore that accepts two parameters: the test number (1 through 3) and the score. Also provide a method called getTestScore that accepts the test number and returns the appropriate score Provide a method called average that computes and returns the average test score for this student. Modify the toString method such that the test scores and average are included in the description of the student. Modify the driver class main method to exercise the new Student methods. (c++ language)
Create a PhoneListing class that uses the Name class for one of its instance variables. Remember the instance data in the Name class is private to the class and must be accessed through its methods.Add additional instance variables to the PhoneListing class for the phone number. The phone number should be broken down into three parts, area code, city code, and local code.Create all appropriate methods for the new class, including the following three methods: equals(PhoneListing):boolean, an equality of state method that returns true if the objects contain the same name and phone number. compareTo(PhoneListing):int, a comparison method that returns -1 if the calling PhoneListing object should precede the argument PhoneListing object, 1 if the calling PhoneListing object should come after the argument PhoneListing object, and a 0 if they are equal. Use last, first, middle, phone number as the ordering values. example:Adams, Alex, Henry, (609)473-2101 Adams, George, Henry, (509)373-1101…

Chapter 4 Solutions

Absolute Java (6th Edition)

Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Java Math Library; Author: Alex Lee;https://www.youtube.com/watch?v=ufegX5o8uc4;License: Standard YouTube License, CC-BY