007-002-010
Object Creation: Basic Operations
Easy
Problem Description
Object Creation: Basic Operations
In this problem, you will declare a Car class with a String field model.
Learning Objective: Understand how to define fields in a class used when creating objects (instances)
Overview
Create a Car class representing a car. Test code will create objects, set field values, and verify behavior.
Specifications
- Create a
Carclass - Define a String field
model(default access modifier) - The field must be directly accessible from outside the class
Verification Example
Car myCar = new Car();
myCar.model = "Toyota";
System.out.println("Model: " + myCar.model);
// Output: Model: Toyota
Ready to Try Running Code?
Log in to access the code editor and execute your solutions for this problem.
Don't have an account?
Sign Up