Program: Classes and Instantiation Demonstration
Description: This program introduces beginner programmers to the concept of classes, objects, and instantiation in Java. It includes a basic example of a class with attributes and methods, and how to create and use objects of that class.
Key Concepts:
1. Define a class called "Car".
- Add attributes: make (String), model (String), year (int).
- Add a method: displayCarInfo() to print the car's details.
2. In the main program, create a new object of the "Car" class.
3. Assign values to the attributes of the Car object.
4. Call the displayCarInfo() method to display the car details.
// Step 1: Define the class
class Car {
// Attributes
String make;
String model;
int year;
// Method to display car details
void displayCarInfo() {
System.out.println("Car Details:");
******* you will need to fill in the rest of the java code *******
You will drop off 5 files into Google Classroom:
• Your files will be: (Remember the python program is dropped off first.)
• PX_lastname_CarClass.java (Java program that is instantiated)
• PX_lastname_CarClassTester.java (Java program that instantiates the object)
• PX_lastname_CarClass.png (Screenshot of class notes)
• PX_lastname_CarClass.png (Screenshot inside Eclipse)
• PX_lastname_CarClass.mp4 (Video running the program)
If you do not understand this assignment,
ask Mr. Cusack and/or attend tutorials.