Starting Out with Java: Early Objects, Student Value Edition (6th Edition)
6th Edition
ISBN: 9780134457918
Author: GADDIS, Tony
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 3, Problem 3MC
An object is a(n) _____.
- a. blueprint
- b. attribute
- c. variable
- d. instance
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Create a class Rectangle with attributes length and width with are variables, each ofwhich defaults to 1. Provide methods that calculate the rectangle’s perimeter and area.It has set and get methods for both length and width. The set methods should verify thatlength and width are each floating-point numbers (double datatype) larger than 0.0 andless than 20.0. Write a Test class to test all the methods from class Rectangle
Create a class Rectangle with attributes length and width with are variables, each ofwhich defaults to 1. Provide methods that calculate the rectangle’s perimeter and area.It has set and get methods for both length and width. The set methods should verify thatlength and width are each floating-point numbers (double datatype) larger than 0.0 andless than 20.0. Write a Test class to test all the methods from class Rectangle.RectangleTest.java source file should looks like this:class Rectangle{//data fileds//methods}//end Rectangle classpublic class RectangleTest{
//main method}//end RectangleTest class
Design a class named Rectangle to represent a rectangle. The class must have the following:
• double data fields named width and height. The default values are 1 for both width and height A no-argument constructor that creates a default bag.
A constructor that creates a rectangle with the specified width and height A getParameter() method to return the perimeter.
• A getArear() method to return the area of the Rectangle.
Create two Rectangle objects. One with width 4.0 and height 10.0. The other object has width 6.3 and height 10.5.
Chapter 3 Solutions
Starting Out with Java: Early Objects, Student Value Edition (6th Edition)
Ch. 3.1 - In this chapter, we use the metaphor of a...Ch. 3.1 - Prob. 3.2CPCh. 3.1 - When a variable is said to reference an object,...Ch. 3.1 - A string literal, such as Joe, causes what type of...Ch. 3.1 - Prob. 3.5CPCh. 3.1 - Prob. 3.6CPCh. 3.1 - Prob. 3.7CPCh. 3.1 - Prob. 3.8CPCh. 3.1 - Prob. 3.9CPCh. 3.1 - What is a stale data item?
Ch. 3.3 - Assume that r1 and r2 are variables that reference...Ch. 3.4 - How is a constructor named?Ch. 3.4 - What is a constructors return type?Ch. 3.4 - Prob. 3.14CPCh. 3.8 - Prob. 3.15CPCh. 3.8 - When designing an object-oriented application, who...Ch. 3.8 - How do you identify the potential classes in a...Ch. 3.8 - What are a classs responsibilities?Ch. 3.8 - What two questions should you ask to determine a...Ch. 3.8 - Will all of a classs actions always be directly...Ch. 3 - This is a collection of programming statements...Ch. 3 - A class is analogous to a(n) _______. a. house b....Ch. 3 - An object is a(n) _____. a. blueprint b. attribute...Ch. 3 - This is a class member that holds data. a. method...Ch. 3 - This key word causes an object to be created in...Ch. 3 - This key word causes a value to be sent back from...Ch. 3 - This is a method that gets a value from a classs...Ch. 3 - This is a method that stores a value in a field or...Ch. 3 - When the value of an item is dependent on other...Ch. 3 - This is a method that is automatically called when...Ch. 3 - When a local variable has the same name as a...Ch. 3 - If you do not write a constructor for a class,...Ch. 3 - A classs responsibilities are __________. a. the...Ch. 3 - Prob. 14TFCh. 3 - True or False: When passing an argument to a...Ch. 3 - Prob. 16TFCh. 3 - True or False: Each instance of a class has its...Ch. 3 - True or False: When you write a constructor for a...Ch. 3 - True or False: To find the classes needed for an...Ch. 3 - Find the error in the following class: public...Ch. 3 - Prob. 2FTECh. 3 - The following statement attempts to create a...Ch. 3 - Design a class named Pet, which should have the...Ch. 3 - Look at the following partial class definition,...Ch. 3 - Look at the following description of a problem...Ch. 3 - What is the difference between a class and an...Ch. 3 - A contractor uses a blueprint to build a set of...Ch. 3 - What is an accessor method? What is a mutator...Ch. 3 - is it a good idea to make fields private? Why or...Ch. 3 - If a class has a private field, what has access to...Ch. 3 - Prob. 6SACh. 3 - Assume a program named MailList.java is stored in...Ch. 3 - Prob. 8SACh. 3 - Why are constructors useful for performing...Ch. 3 - Prob. 10SACh. 3 - What is the difference between an argument and a...Ch. 3 - Under what circumstances does Java automatically...Ch. 3 - What do you call a constructor that accepts no...Ch. 3 - Employee Class Write a class named Employee that...Ch. 3 - Car Class Write a class named Car that has the...Ch. 3 - Personal Information Class Design a class that...Ch. 3 - Temperature Class Write a Temperature class that...Ch. 3 - Retail Item Class Write a class named RetailItem...Ch. 3 - Payroll Class Design a Payroll class that has...Ch. 3 - TestScores Class Design a TestScores class that...Ch. 3 - Circle Class Write a Circle class that has the...Ch. 3 - Pet Class Design a class named Pet, which should...Ch. 3 - Patient Charges Write a class named Patient that...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Are the Book objects you have implemented immutable? Justify your answer.
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
In a Python class, how do you hide an attribute from code outside the class?
Starting Out with Python (3rd Edition)
3.12 (Date Create a class called Date that includes three pieces Of information as data
members—a month (type ...
C++ How to Program (10th Edition)
Give an example of each of the following, other than those described in this chapter, and clearly explain why y...
Modern Database Management (12th Edition)
Budget Analysis Design a program that asks the user to enter the amount that he or she has budgeted for a month...
Starting Out with Programming Logic and Design (4th Edition)
Write a program to print the value of EOF.
C Programming Language
Knowledge Booster
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
- Create a class Car with parameters companyName, color, maxSpeed (Not more than 150) andcategory. Use appropriate data types and access specifiers. Use default constructor to create objectsof cars. (JAVA)arrow_forwardCreate a Shape class that shall have color and filled instance variables of enum Color and boolean type. The filled boolean variable shall show, whether the shape is filled (colored). The enum Color shall be defined within the class having 4 color names (choose any four). Also define getArea and getPerimeter method in Shape class, both shall return 0. Create Rectangle class with length and width attributes and a Circle class with radius attribute, of type double. Properly encapsulate all fields. Circle and Rectangle shall extend Shape class and override getArea and getPerimters methods as per its type and specific formula. In Test class, create an object of Rectangle and Circle, by initializing all attributes in constructor and print both shapes' area and perimters. In Test class, define a static method with following signature, public static void printEachShapeCount(Shape... shapes) As you know, the parent type variable can hold the reference of any child class object. That…arrow_forwardjava. Check ‘n Shop is a grocery supermarket in South Africa that provides a loyalty program to customers on a monthly basis. Customers earn points based on the number of visits and the amount they spend, especially on healthy foods during the month. The private data fields for the Shopper object class are: See attached image The constructor must assign values of the parameters to the private data field variables. The static variable should be incremented by one in the constructor. The increaseLoyaltyPoints() method calculates the number of loyalty points based on the amount a customer spent at the supermarket. All customers receive 100 free points each month. Use the following criteria to calculate the additional points earned to be added to the 100 free points: For every four rands (R4) spent, one loyalty point is awarded. Make use of an appropriate Math class function to round up the loyalty points to a whole number. The updateHealthLevel() method receive the total amount…arrow_forward
- Define the Circle2DYourLastName class that contains: Two double data fields names x and y that specify the center of the circle withgetter methods. A double data field radius with getter method. A constructor that creates a circle with specified x, y, and radius. A method findTypeOfIntersection to determine and return types ofintersection as string (contained, overlap, or separate).Design a user class that prompts the user to enter the coordinates of the center andradius of two circles and displays the type of intersection. Allow the user to repeat yourprogram using a ConfirmDialog Box.arrow_forwardYou will create a class called Square. Length will represent the length of one side which is an integer.You should create the constructor, an instance variable, a getter method for the length of a side, a getArea method and a toString method. The area of a square = length * length.Your toString method should be written such that it would return a String of the form "Square with side length: 8” (if the side length was 8) public class Square { //create one instance variable called length //create the constructor with one parameter //create your getter method to get the length of one side with return type integer //create the getArea method with return type integer //create the toString method }arrow_forwardIn this lab, you will create a programmer-defined class and then use it in a Java program. The program should create two Rectangle objects and find their area and perimeter. Instructions Make sure the class file named Rectangle.java is open. In the Rectangle class, create two private attributes named length and width. Both length and width should be data type double. Write public set methods to set the values for length and width. Write public get methods to retrieve the values for length and width. Write a public calculateArea()method and a public calculatePerimeter() method to calculate and return the area of the rectangle and the perimeter of the rectangle. Open the file named MyRectangleClassProgram.java. In the MyRectangleClassProgramclass, create two Rectangle objects named rectangle1 and rectangle2. Set the length of rectangle1 to 10.0 and the width to 5.0. Set the length of rectangle2 to 7.0 and the width to 3.0. Print the value of rectangle1’s perimeter and area, and then…arrow_forward
- 1: Create a enum PizzaType, which has the following entries: PIZZA_TYPE_PLAIN, PIZZA_TYPE_PEPPERONI, PIZZA_TYPE_SAUSAGE, PIZZA_TYPE_VEGGIE 2: Create a class PizzaSalesBarChart, which inherits from StoreSalesBarChart. Create a addPizzaSales(enum PizzaType) method. Return different value for different types of pizza. Create it own version of StoreSalesBarChart setDailySales(String salesName). This method should create a PizzaSalesBarChart instance, generate a random pizza type value 10 times and call addPizzaSales for each pizza type value, then return the PizzaSalesBarChart instance. In JoePizzaShop's main method, instead of calling "StoreSalesBarChart.setDailySales(salesName)", call " PizzaSalesBarChart .setDailySales(salesName)" and see what happens.arrow_forwardCreate a method named getCircleDiameter that takes a radius of double type as the parameter. The method should return the diameter of a circle. To compute the diameter of a circle, multiply the radius by 2.Create a struct named Product where its fields are code, description, and price. Create a class named Person with an instance variable named full_name. Declare one (1) constructor without a parameter and initialize the variable with a default value.Create a class named Account with an instance variable named account_number. Make this class a member of the Accounts namespace.arrow_forwardPlease check the images for the whole question. Thank you. /* TestCarSensor.java - program to test the CarSensor class.*/public class TestCarSensor{public static void main (String[] args){// 1. declare CarSensor objectsCarSensor generic = new CarSensor(); // default sensor, all values "zero"CarSensor tempCel = new CarSensor("temperature sensor", -50, +300, "C"); // temperature sensor (Celsius)CarSensor speed = new CarSensor("speed sensor", 0, 200, "km/h"); // speed sensor (kms/hour)CarSensor speed2 = new CarSensor("speed sensor 2", 0, 200, "m/h"); // speed sensor 2 (miles/hour)// 2. test changing desc and limitsSystem.out.println ();System.out.println ( generic ); // display generic sensor (zero)generic.setDesc ("special sensor"); // change descriptiongeneric.setLimits (-5,5,"units"); // change limitsSystem.out.println ( generic ); // display generic sensor again// 3. test displaying object (calling .toString() )System.out.println ();System.out.println ( tempCel );System.out.println (…arrow_forward
- Hello. Please help me complete the code. A picture of the problem statement has been provided, as well as the code to be completed and the driver code. Please make sure the test cases are passed. /** This class models a ball that bounces off walls.*/public class Ball{ // Instance variables /* Your code goes here */ /** Constructs a ball at (0, 0) traveling northeast. @param rightWall the position of the wall to the right @param topWall the position of the wall at the top */ public Ball(int rightWall, int topWall) { /* Your code goes here */ } /** Moves the ball. */ public void move() { /* Your code goes here */ } /** Turns the ball direction 90 degrees clockwise. */ private void turn() { /* Your code goes here */ } /** Gets the current x-position. @return the x-position */ public int getX() { /* Your code goes here */ } /** Gets the current y-position. @return…arrow_forwardCreate an application class named LetterDemo that instantiates objects of two classes named Letter and CertifiedLetter and that demonstrates all their methods. The classes are used by a company to keep track of letters they mail to clients. The Letter class includes auto-implemented properties for the name of the recipient and the date mailed. Also, include a ToString() method that overrides the Object classs ToString() method and returns a string that contains the name of the class (using CetType and the Letters data field values. Create a child class named CertifiedLetter that includes an auto-implemented property that holds a tracking number for the letter.arrow_forwardCreate an application named TurningDemo that creates instances of four classes: Page, Corner, Pancake, and Leaf. Create an interface named ITurnable that contains a single method named Turn The classes named Page, Corner, Pancake, and Leaf implement ITurnable. Create each classs Turn() method to display an appropriate message. For example, the pages Turn() method might display You turn a page in a book.arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTEBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Memory Management Tutorial in Java | Java Stack vs Heap | Java Training | Edureka; Author: edureka!;https://www.youtube.com/watch?v=fM8yj93X80s;License: Standard YouTube License, CC-BY