Practical Coding in Java

Learn to write and validate your own code

Darren Kessner, PhD

(revised January 9, 2026)

Previous: Coding Exercises: Loops and Algorithms

4. Classes and Objects

In this chapter we discuss the fundamental concept of object oriented programming: classes and objects.

We have already seen the String class, and objects of the String class:

String s = "Hello, world!";

We also call an object’s class the type of the object. In Java we can define our own classes, i.e. we can create our own types of objects.


Next: