EBK JAVA PROGRAMMING
8th Edition
ISBN: 9781305480537
Author: FARRELL
Publisher: CENGAGE LEARNING - CONSIGNMENT
expand_more
expand_more
format_list_bulleted
Question
error_outline
This textbook solution is under construction.
Students have asked these similar questions
Assume method testQuestion() is a method in the Purchase class. Assume the Purchase class has a constructor that has parameters of name, groupCount, groupPrice, and numberBought.
public Purchase testQuestion(Purchase p1, int newX)
{
newX = 20;
this.setName("green beans");
p1.setName("corn");
Purchase p2 = new Purchase("broccoli", 5, 4.50, 10);
return p2;
}
Referring to the above method, list the output that would be printed by Sysyem.out.println() when the following PurchaseDemo2 is executed.
public class PurchaseDemo2
{
public static void main(String[] args)
{
Purchase tomsPurchase = new Purchase("squash",4,3.50,6 );
Purchase jillsPurchase = new Purchase("carrot",8,1.99,4 );
Purchase billsPurchase;…
Urgent Quick Question
Write an equals method for the StepsFitnessTracker class that tests whether the one object is equal to another object that is passed as an argument (Object otherObject). The Object superclass provides an equals method that tests if two object references are equal. Your new equals method should override the Object equals method, and should test the following: • Return true if the current (this) object, and otherObject are identical references (hint: you can use the == operator for this). • Returns false if otherObject is null. • Returns false if the current (this) object and otherObject have different classes (hint: you can use the getClass() method provided by the Object superclass, see the Java 8 API documentation for details). • Casts otherObject to a StepsFitnessTracker, and tests for equality of each instance variable1 , if the instance variables are the same the method should return true. Now write an equals method for the DistanceFitnessTracker and…
Urgent Quick Question
Write an equals method for the StepsFitnessTracker class that tests whether the one object is equal to another object that is passed as an argument (Object otherObject). The Object superclass provides an equals method that tests if two object references are equal. Your new equals method should override the Object equals method, and should test the following: • Return true if the current (this) object, and otherObject are identical references (hint: you can use the == operator for this). • Returns false if otherObject is null. • Returns false if the current (this) object and otherObject have different classes (hint: you can use the getClass() method provided by the Object superclass, see the Java 8 API documentation for details). • Casts otherObject to a StepsFitnessTracker, and tests for equality of each instance variable1 , if the instance variables are the same the method should return true. 1 To test for equality of each instance variable, you might want to…
Knowledge Booster
Similar questions
- Assume that you have created a class named MyClass. The header of the MyClass constructor can be ____________. public MyClass() public MyClass (double d) Either of these can be the constructor header. Neither of these can be the constructor header.arrow_forwardAt most, a class can contain ____________ method(S). 0 1 2 any number ofarrow_forwardCreate a class called Invoice that a hardware store might use to represent an invoice for an item sold at the store. An Invoice should include four pieces of information as instance variable Part number(type String) Part description(type String) Quantity of the item being purchased (type int) Price per item (double). Your class should have a constructor that initializes the four instance variables. Provide a set and a get method for each instance variable. In addition, provide a method named getInvoice Amount that calculates the invoice amount (i.e., multiplies the quantity by the price per item), then returns the amount as a double value. If the quantity is not positive, it should be set to 0. If the price per item is not positive, it should be set to 0.0. Write a test application named InvoiceTest that demonstrates class Invoice’s capabilities.arrow_forward
- A teen ager Sport Club offers many sports to the registered members write a java code to keep facilitate the players. Create a class name Play Create the following method name checkMatchSchedule(): This method will display the match schedule. checkMatchSchedule():(): This method will display the match practice schedule. rules(): display the sport rule. Create the following classes: Tennis, Cricket and football. These classes will inherit the play class and override the parent methods. Create a Player class: playerId, name , height, weight, age. checkMatchSch(): This method will take input from user inquiring which sport match schedule would he like to view and display the schedule of the respective Sport. checkRules():This method will take input from user inquiring which sport rules would he like to view and display the rule of the respective Sport. Create a Main class and test the methods.arrow_forward5) In a class definition, what type of method uses the values of the object's instance variables without changing them? a. constructor b. accessor C. instance d. mutator 17) What is the value of r after the following code executes? mySet = (2, 3, 5, 7, 11) yourSet = {5, 7, 2, 11, 3) r = yourSet == mySet a. (5, 7, 2, 11, 3} b. {2, 3, 5, 7, 11} c. True d. error 8) Assume x is equal to O and y is equal to 5. Which comparison operation does not return False? a. x == y or y b. y 5 and y C. (x > y) and x d. x > 0 and Nonearrow_forwarda- Write a java class named Account which contains: private data field named number of type int private data field named balance of type double no argument constructor An argument constructor to create Account object with specified number and balance. A method toString() that returns number and balance as a String Set and Get Methods for all the data fields b- Write java code for the test class named testAccount which contains: Main method Create this object of type account à number:30214 balance:950.23 Change the balance by using set method to 900.0 Print the object by using toString method.arrow_forward
- a. Write a class named Student has the following data fields and methods: private int Id private double GPA Constructor to create a Student object with specified name, address, Id and GPA. Accessors and mutators methods for Id and GPA data fields (get and set). A method toString () that returns Id, name and address and GPA. b. Write a test program that creates a Student object with Id:123 Name: Ahmed address: Muscat grade: 2.55 & then call toString () method to display Id, name and address and GPA.arrow_forwardDesign FullTimeEmployee class and PartTimeEmployee class which inherit Employee class so that the following code provides the expected output.[addFullTimeEmployee() and addPartTimeEmployee() methods should work any number of parameters assuming that the parameter number will be an even number and greater than 1]class Employee: total_employee = 0 def __init__(self, name, work_hour): self.name = name self.work_hour = work_hour def __str__(self): s = “Department: ”+self.name+", Work hours: "+str(self.work_hour) return s# Write your codes here.# Do not change the following lines of code.p1 = FullTimeEmployee(“Finance”, 40 )print("=================================")p1.addFullTimeEmployee(“Bob”, 12, “Carol”, 18, “Mike”, 15)print("=================================")print(p1)print("=================================")p2 = PartTimeEmployee(“Others”, 25)print("=================================")p2.addPartTimeEmployee(“David”, 12, “Simon”,…arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,EBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage