Skip to main content

Section 3.1 Object Oriented Programming

Java is an object-oriented programming language. That means that one of the primary ways of organizing our programs is in terms of objects. Objects are a kind of value that combines data and the code that operates on that data into a single unit.
Objects are defined in Java by writing classes which provide a blueprint for creating objects of a certain kind, describing the data and code that all instances of that class have. Sometimes classes and objects are used to model things in the real world, such as if we made a Student class to represent students in a school. Other times classes are just ways of organizing different parts of our programs that may not correspond to anything in the world outside the computer. But in Java all programs are built out of classes. This is why, as you saw in the previous chapter, every Java programs starts with public class: the first thing we have to do when we write a Java program is define at least one class. You have already seen how to define classes in Java. It’s unavoidable for even the simplest of programs.
You have attempted of activities on this page.