E ExamMaster

Object-Oriented Programming through Java · Language Basics

What OOP Is

In Object-Oriented Programming through Java because the rest of the course writes classes and objects — you need the idea of a thing with facts and behaviour before any Java…

Meera buys a cinema ticket: a show, a seat, a price. This lesson treats that ticket as an object — one thing that knows facts and can do work — and treats Ticket as the shared idea many such objects come from. No Java class syntax yet. The next lesson opens a .java file.

  • Object-Oriented Programming through Java
  • Easy level
  • 5 concepts

1A program as a small world of things

A Java program in this course is not first a list of steps. It is a small world of things that know facts and can do work.

Meera buys a cinema ticket. The ticket is the thing the program should talk about — not a pile of loose numbers named a, b and c with no owner.

Figure. Meera is a person in the story; the ticket is the object the program will talk about. The arrow is the purchase, not a Java method yet.

How it works

  1. A program as a small world of thingsObject-oriented code is organised around things that know facts and can do work, not around a loose pile of numbers.

2An object is one particular thing

An object is one particular thing in that world. Meera's ticket is not tickets in general: it is seat A12 for the 6pm show, price 200 rupees.

Arun can hold a different ticket at the same time. Each object has its own copy of the facts. Changing Meera's seat does not move Arun.

Figure. Two ticket objects sit side by side. Same kind of thing, different facts. There is no arrow between them: one does not own the other.

Two objects, two sets of facts
ObjectShowSeatPrice
Meera's ticket6pmA12200
Arun's ticket6pmB7200

3A class is the shared idea

A class is the shared idea those objects come from. Ticket says every ticket has a show, a seat, and a price.

The class is the mould; each printed ticket is an object. You do not need Java syntax yet: one idea, many instances.

Figure. Ticket at the top is the class — the idea. The two objects below are instances of that idea. The arrows mean made from, not a method call.

How it works

  1. A class is the shared ideaOne class, many objects. The class names the facts; each object fills them in.

4Hide the inside; offer a small public surface

Encapsulation means the object's insides stay its business. Other code should not reach in and rewrite the price.

It asks the ticket to do something — print itself, say whether it is a student fare — through a small public surface. Later Java will use private fields and public methods for this idea, not as decoration.

Figure. The outer box is what other code may ask for. The inner box is the price, which stays the ticket's business. Not to scale as a real class file — it is a boundary picture.

How it works

  1. Hide the inside; offer a small public surfaceAsk through the public surface. Do not reach in and rewrite the price.

5Idea first, then the .java file

The next lessons teach Java's file shape, types, operators, and control. Those are how you write.

This lesson is what you are writing about. If you skip the object idea, the first line of a Java file looks like a spell instead of a door into a class.

Figure. Treat the ticket as an object before you open a .java file. This lesson is what you are writing about. Syntax is how you write the idea down.

How it works

  1. Idea first, then the .java fileTreat the ticket as an object before you open a .java file. Syntax is how you write the idea down.

Coding lab. Two tickets, two objects runs in the app, with checks on your output.

Notes

  • In Object-Oriented Programming through Java because the rest of the course writes classes and objects — you need the idea of a thing with facts and behaviour before any Java syntax.
  • An object is one particular thing: Meera's ticket for seat A12 is not the same object as Arun's ticket for seat B7.
  • A class is the shared idea those objects come from. Encapsulation keeps the insides private and offers a small public surface.

Exam traps & shortcuts

  • If you cannot name the thing and the facts it holds, you are not ready to write a class yet.
  • Do not start at public static void main. Start at the ticket.

Recap

A program is a world of things, an object is one thing, a class is the idea, and the insides stay hidden.

A program as a small world of things
Object-oriented code is organised around things that know facts and can do work, not around a loose pile of numbers.
An object is one particular thing
Meera's ticket for seat A12 is not the same object as Arun's ticket for seat B7.
A class is the shared idea
The class is the mould; each printed ticket is an object.
Hide the inside
Other code should not reach in and rewrite the price.

Practise What OOP Is

Reading is free and needs no account. Practice, mocks and progress live in the app.

  • Timed mocks scored with the real marking scheme
  • Readiness tracked per topic, kept on your device
Continue with Google — freeNo card, no trial. Works offline once installed.