Declaration and Implementation
In this lesson, you will learn about the declaration and implementation details of a class.
We'll cover the following...
We'll cover the following...
The written code of a class and its attributes are known as the definition or implementation of the class.
Declaration
In Java, we define classes in the following way:
The class keyword tells the compiler that we are creating our custom class. All the members of the class will be defined within the class scope.
Creating a class object
The name of the class, ClassName, will be used to create an instance of the class in our main program. We can create an object of a class by using the keyword new:
Implementation of a Car class
Let’s implement the Car class illustrated below: