Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need the complete code for numbers 9,16,17 and 18. Need to show how the answer

ID: 3749952 • Letter: I

Question

I need the complete code for numbers 9,16,17 and 18. Need to show how the answers were resulted. Assume that you have created a class named MyClass. The header of the Myclass constructor can be a. public MyClass O b. public MyClass (double d) c. Either of these can be the constructor header. d. Neither of these can be the constructor header. 8. 9Assume that you have created a class named DemoCar. Within the MainO method Creu of this class, you instantiate a Car object named myCar and the following statement executes correctly: WriteLineC"The Car gets (oj miles per gallon", myCar.ComputeMpgO) Within the Car class the ComputeMpgO method can be Giabslà any neasin a. public and static b public and nonstatic c. private and static d. private and nonstatic Assume that you have created a class named TermPaper that contains a character field named letterGrade. You also have created a property for the field. Which of the following cannot be true? a. The property name is letterGrade. b. The property is read-only. c. The property contains a set accessor that does not allow a grade lower than 'C' d. The property does not contain a get accessor. A this reference is 10. 11. a. implicitly passed to nonstatic methods b. implicitly passed to static methods c. explicitly passed to nonstatic methods d. explicitly passed to static methods 12. When you use an instance variable within a class's nonstatic methods, you explicitly refer to the method's this reference. a. must b. can C. cannot d. should (even though it is not required)

Explanation / Answer

Answer 16 : In a C++ lanuage we have delete operator to manually release objects, but in Java we get a different approach. Java handles deallocation for you automatically. This technique of automatically deleting objects is called garbage collection. So there is no need to delete objects explicitly as it is done sporadically during the execution of your program in Java. Hence, there is no destructor in Java and we can't call it.

------------------------------------------------------------------------------------------------------------------------------------------------------------

Anwer 18 : In Java array starts from 0(zero) and not 1. Java uses zero based indexing so the array of 200 furniture objects named myChairs will get zero as index for first element in array. Hence, last element of the array will have index of 199.

-------------------------------------------------------------------------------------------------------------------------------------------------------------

Answer 17: To create 5 objects of a class in Java, you will need to call constructor of a class 5 times. For example:

Public class Car

{

char color,
char brand;
float cost;

}

// to call this class, firstly you will need to create an object
//suppose we are creating 5 instances for 5 different cars

Car myCar1 = new Car();
Car myCar2 = new Car();
Car myCar3 = new Car();
Car myCar4 = new Car();
Car myCar5 = new Car();
// in the above example we created 5 objects/instances of Class "Car"
//everytime object is created function "Car()" is called, and this is the default constructor of class "Car"

Hence, to delete these 5 objects of class "Car", garbage collector will call destructor 5 times to delete all objects.