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
In this exercise, you are going to build on your Circleclass from the previous exercise. You are going to add 2 method, areaDifference and perimeterDifference. Both methods take a doubleradius of a second circle and return the difference from the current circle. For example, if you create a Circle object with a radius of 4 and call areaDifference(3), you will return the diffence between the area of a circle with radius 4 and the area of a circle with a radius of 3. perimeterDifferencewould be the same. Make sure you create at least one Circle and test and print the results of your methods.   given: public class Circle{private double radius;public Circle(double theRadius){radius = theRadius;}// Add a method called area that returns the area of a circle// using Math.PIpublic double area(){return Math.PI*radius*radius;}// Add a method called perimeter that returns the perimeter of a// circle using Math.PIpublic double perimeter(){return Math.PI*2*radius;}}
For this project you will have to write two classes.Class Rectangle is a class that represents an axis-aligned rectangle. ClassRectangleTester is the driver class, used to test the Rectangle class.Class Rectangle:An instance of the class Rectangle represents a valid axis-aligned rectangle. It has severalinstance variables that one needs to use to describe a rectangle, as well as methods thatoperate on these variables.Rectangle instance variables:Class Rectangle will have the following instance variables:• x – a double that represents the x coordinate of the lower left vertex of therectangle• y – a double that represents the y coordinate of the lower left vertex of therectangle• width – a double that represents the width of the rectangle• height – a double that represents the height of the rectangle• color – a String that represents the color of the rectangleFor the rectangle to be valid, the coordinates of all vertices must be between 0 and 1inclusive. The color can be one of the…
Write a class called Circle that contains:a. Three private instance variables: radius (of the type double), color (of thetype String), and area (of type double).b. Two constructors - a default constructor with no argument (default value of radiusis 2.0, and color is Green) and a parameterized constructor, which initializes onlythe radius and the color variables.c. Getter and setter for the radius and color variables.d. Two public methods: calculateArea(), and getPerimeter, which return the areaand perimeter of a circle instance, respectively. Both methods have return.Then write a driver class that tests the Circle class. In the driver class, create two objectsof Circle class, one that tests the default constructor of the Circle class (here no user inputis required) and then get the color, radius, area, and perimeter of that object and displaythem. The second object should test the parameterized constructor (here you need to ask userto give you input to initialize the class variables).…

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