Topic 1 - Variables and Data Types
Topic 2 - Conditionals and Strings
Topic 3 - Loops
Topic 4 - Arrays
Topic 5 - File Handling
Semester 1 Projects
Topic 6 - Classes/Objects and Methods
Topic 7 - ArrayLists
Semester Projects

What is a Class and an Object?

class is used to define a type (classify something). The class defines what objects of the class need to know (data or fields) and do (behaviors or methods).

There are many classes that are part of the Java language, but you only have to know a few of these for this course (StringMathSystemListArrayList).

The real power of Java is the ability to create your own classes (define your own types). Instead of having to be constrained to the data types we learned in the previous unit, you can create a new type for anything that you can imagine.

Classes create objects, and the objects do the actual work in an object-oriented program. You can think of a class as a cookie-cutter. It is used to create the cookies (objects) and can be used to create as many cookies (objects) as you want. A class can also be thought of as a factory that produces objects.

You can also think of a class as the type or classification. The following picture has lots of cats (objects of the type Cat).

If you go to a restaurant, you will be seated by the greeter, the waiter will take your order, and the chef will cook your food. What do we mean by a greeter, waiter, and chef? Those are classifications or types of workers in a restaurant. Java has this same concept. When we create a new class we are defining a new type (a new classification) to the computer.

Each type can have abilities or behaviors or actions (called methods in Java) and properties (called fields in Java). After you define a type, you can use it to create objects of that type. All objects created from a class will have the properties and abilities/behaviors defined in that class.