Consider a base class named 'Vehicle' in Java, with a field 'name'. You need to create an object of 'Vehicle', assign the value 'Honda' to its 'name' field, and finally print the 'name' field using System.out.println(). Fill the blanks in the code provided to create an instance of 'Vehicle', assign the value, and print it.
Computer scienceProgramming languagesJavaCode organizationObject-oriented programmingClasses and objectsClasses and members
Objects and their properties
Creating and printing a 'Vehicle' object in Java
Report a typo
Fill in the gaps with the relevant elements
public class {
String name;
public static void (String[] args) {
Vehicle car = Vehicle();
car.name = "Honda";
System.out.println(car.name);
}
} ___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.