Complete the code to create a new object of class Car.
Car myCar = new [1]();In Java, to create a new object, you use the class name with new. Here, Car is the class name.
Complete the code to call the constructor of class Person with a name parameter.
Person p = new Person([1]);The constructor expects a name, which is a string. Strings in Java are written inside double quotes.
Fix the error in the code to properly destroy an object reference.
myObject = [1];In Java, to remove a reference to an object so it can be garbage collected, assign null to the variable.
Fill both blanks to create an object and call its method.
Car [1] = new [2](); [1].startEngine();
First, we name the object myCar. Then, we create a new Car object. Finally, we call the method on myCar.
Fill all three blanks to create a Person object, assign it to a variable, and call a method.
Person [1] = new [2]([3]); [1].sayHello();
We name the variable person1, create a new Person with the name "Bob", then call sayHello() on person1.