Respuesta :
Answer:
Explanation:
- In Java, a Constructor is similar to that of a method which will be called when creating a new object for the class.
- There is no return type for a Constructor.
- public Vehicle (String color, String type)
{
colourName = color;
typeName = type;
}
- In Java, you can use new operator to create an object of a class.
- Here, the object for the class Vehicle is created like Vehicle vehicle = new Vehicle("Pink", "Car");
- When creating the object of the class, the new operator calls the constructor.
- If there is no constructor defined explicitly, a default constructor is created by the compiler.