Complete the code to declare a constructor for the class.
public class Car { String model; public [1](String model) { this.model = model; } }
The constructor name must exactly match the class name and have no return type.
Complete the code to create an object using the constructor.
Car myCar = new [1]("Toyota");
To create an object, use the class name with the new keyword and call the constructor.
Fix the error in the constructor declaration.
public class Book { String title; public void [1](String title) { this.title = title; } }
Constructors must not have a return type, so remove 'void' and use the class name exactly.
Fill both blanks to complete the constructor and initialize the field.
public class Student { int age; public [1](int [2]) { this.age = age; } }
The constructor name must match the class name 'Student'. The parameter name should be 'age' to assign correctly.
Fill all three blanks to create a constructor that initializes two fields.
public class Laptop { String brand; int price; public [1](String [2], int [3]) { this.brand = brand; this.price = price; } }
The constructor name must be 'Laptop'. The parameters should be 'brand' and 'price' to assign values correctly.