0
0
Javaprogramming~15 mins

Object lifetime in Java - Interactive Code Practice

Choose your learning style8 modes available
ads_clickPractice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a new object of class Car.

Java
Car myCar = new [1]();
🎯 Drag options to blanks, or click blank then click option
AVehicle
Bcar
CCar
DObject
Attempts:
3 left
2fill in blank
medium

Complete the code to call the method that destroys an object reference.

Java
myCar = [1];
🎯 Drag options to blanks, or click blank then click option
Anull
Bvoid
Cremove
Ddelete
Attempts:
3 left
3fill in blank
hard

Fix the error in the code that tries to finalize an object.

Java
protected void [1]() throws Throwable {
    System.out.println("Cleaning up");
    super.finalize();
}
🎯 Drag options to blanks, or click blank then click option
Afinalize
Bdelete
Ccleanup
Ddestroy
Attempts:
3 left
4fill in blank
hard

Fill both blanks to create an object and then remove its reference.

Java
Car [1] = new [2]();
🎯 Drag options to blanks, or click blank then click option
AmyCar
Bcar
CCar
DVehicle
Attempts:
3 left
5fill in blank
hard

Fill all three blanks to create a new object, assign null, and print a message.

Java
Car [1] = new [2]();
[1] = [3];
System.out.println("Object reference removed");
🎯 Drag options to blanks, or click blank then click option
AmyCar
BCar
Cnull
Dcar
Attempts:
3 left