Introduction To Classes and OBJECTS
Introduction To Classes and OBJECTS
OBJECTS
What is Class??
• A Class is a template/blueprint.
• A Class defines the form of an object
• An object is a specific instance of a
class
EXAMPLE OF CLASS AND OBJECT
Object Vios Object Accent
Length = 16 feet
class Car Length = 13 feet
Passenger Capacity = 4
Top Speed = 230 mph
Passenger Capacity = 4
Top Speed = 220 mph
Passenger Capacity
Object Brio Object Innova
Top Speed Length = 16 feet
Passenger Capacity = 5
Length = 17 feet
Passenger Capacity = 7
Color Top Speed = 250 mph
Color = red
Top Speed = 210 mph
Color = black
• A Class defines the template
• Objects are specific instance of the
template
• Objects are physical thing of the Class
Classes can also contain methods
• Methods can also be members of the Class
• Class methods operate on the Class variables
• Classes should be organized with logical
groupings of variables and methods
Methods - are used to divide and sort functionalities within a class
so that the code will be readable even if it’s long. (sometimes called functions)
Methods are declared within a class, and they are used to perform
certain actions:
class car {
Length
Instance Passenger Capacity
variables Top Speed
Color
void calculateTopSpeed() {
METHOD System.out.println(“This is the Top Speed”);
}
}
Methods - are used to divide and sort functionalities within a class
so that the code will be readable even if it’s long. (sometimes called functions)
Methods are declared within a class, and they are used to perform
certain actions:
CREATING METHODS
CREATING METHODS