(Solved) : Find Error 1 Find Error Following Class Public Class Myclass Private Int X Private Double Q37185787 . . .
Need help on Java


Find the Error 1. Find the error in the following class: public class MyClass private int x; private double y public void MyClass(int a, double b) x a yb 2. Assume that the following method is a member of a class. Find the error. public void total (int value1, value2, value3) return value1 value2 + value3 3. The following statement attempts to create a Rectangle object. Find the error Rectangle boxnow Rectangle 1. 6.12 Look at the UML diagram in Figure 6-17 and answer the following questions: a) What is the name of the class? b) What are the fields? c) What are the methods? d) What are the private members? e What are the public members? Assume that 1imo is a variable that references an instance of the class shown in Figure 6-17. Write a statement that calls setMake and passes the argument “Cadillac” 6.13 Figure 6-17 UML diagram Car – make + getMake0 2. 3. Write the definition of a class Clock. The class has no constructors and three instance variables. One is of type int called hours, another is of type boolean called isTicking, and the last one is of type Inteaer called diff. 4. You should also write a constructor that takes three parameters an int, a boolean, and another int. The constructor should set the instance variables to the valuesprovided. Write the definition of a class Counter containing: 5. An instance variable counter of type int, initialized to 0. A method called increment that adds one to the instance variable counter. It does not accept parameters or return a value A method called getValue that doesn’t accept any parameters. It returns the valueof the instance variable counter a. b. c. Algorithm Workbench 1. Design a class named Pet, which should have the following fields name. The name field holds the name of a pet animal.The animal field holds the type of animal that a pet is. Example values are “Dog”, “Cat” , and “Bird · age. The age field holds the pet’s age. The Pet class should also have the following methods: . setName. The set Name method stores a value in the name field setAnimal. The setAnimal method stores a value in the animal field setAge. The setAge method stores a value in the age field. getName. The getName method returns the value of the name field. getAnimal. The getAnimal method returns the value of the animal field getAge. The getAge method returns the value of the age field. a. Draw a UML diagram of the class. Be sure to include notation showing each field and method’s access specification and data type. Also include notation showing any method parameters and their data types. b. Write the Java code for the Pet class. 6. Show transcribed image text Find the Error 1. Find the error in the following class: public class MyClass private int x; private double y public void MyClass(int a, double b) x a yb 2. Assume that the following method is a member of a class. Find the error. public void total (int value1, value2, value3) return value1 value2 + value3 3. The following statement attempts to create a Rectangle object. Find the error Rectangle boxnow Rectangle 1. 6.12 Look at the UML diagram in Figure 6-17 and answer the following questions: a) What is the name of the class? b) What are the fields? c) What are the methods? d) What are the private members? e What are the public members? Assume that 1imo is a variable that references an instance of the class shown in Figure 6-17. Write a statement that calls setMake and passes the argument “Cadillac” 6.13 Figure 6-17 UML diagram Car – make + getMake0 2.
3. Write the definition of a class Clock. The class has no constructors and three instance variables. One is of type int called hours, another is of type boolean called isTicking, and the last one is of type Inteaer called diff. 4. You should also write a constructor that takes three parameters an int, a boolean, and another int. The constructor should set the instance variables to the valuesprovided. Write the definition of a class Counter containing: 5. An instance variable counter of type int, initialized to 0. A method called increment that adds one to the instance variable counter. It does not accept parameters or return a value A method called getValue that doesn’t accept any parameters. It returns the valueof the instance variable counter a. b. c. Algorithm Workbench 1. Design a class named Pet, which should have the following fields name. The name field holds the name of a pet animal.The animal field holds the type of animal that a pet is. Example values are “Dog”, “Cat” , and “Bird · age. The age field holds the pet’s age. The Pet class should also have the following methods: . setName. The set Name method stores a value in the name field setAnimal. The setAnimal method stores a value in the animal field setAge. The setAge method stores a value in the age field. getName. The getName method returns the value of the name field. getAnimal. The getAnimal method returns the value of the animal field getAge. The getAge method returns the value of the age field. a. Draw a UML diagram of the class. Be sure to include notation showing each field and method’s access specification and data type. Also include notation showing any method parameters and their data types. b. Write the Java code for the Pet class. 6.
Expert Answer
Answer to Find the Error 1. Find the error in the following class: public class MyClass private int x; private double y public voi…
OR