OE-3.1 Java Fundamentals, Classes & Objects

Standard Java as taught in the NPTEL IIT Kharagpur and MIT 6.092 courses — written September 2026

What this is and why it exists

Four ideas hold this whole subject together: abstraction, encapsulation, inheritance, polymorphism. They are stated here and then demonstrated for the rest of the course.

So do not rush past them as vocabulary to be recited. Every later unit is one of them made concrete. Treat them as a definition to memorise and you will meet them again as a surprise.

The other thing to settle early is what actually runs. Java compiles to bytecode, and a virtual machine runs the bytecode. That is the whole of the run-anywhere story, and it is a standard interview opener.

The vocabulary

  • Abstraction — exposing what something does, hiding how.
  • Encapsulation — keeping data and the code that touches it together, and private.
  • Inheritance — a class taking on another's members.
  • Polymorphism — one name behaving differently depending on the object.
  • Bytecode — the intermediate form a Java compiler produces.
  • Virtual machine — the program that executes bytecode.
  • Constructor — the method that runs when an object is created.
  • Overloading — several methods with one name and different parameters.
  • `this` — the object the method was called on.
  • `static` — belongs to the class, not to any object.
  • `final` — cannot be changed or extended.

The mental model

Procedural code organises around what happens. Object-oriented code organises around what things *are*, with the code that touches a thing's data kept beside it. That is the whole shift, and everything else here is machinery for it.

The compilation story is worth getting exactly right. Your source compiles to bytecode, not to machine instructions. A virtual machine then executes that bytecode on whatever platform it is running on. This is the same compiled-or-interpreted distinction from the Programming area: the language did not choose, the implementation did.

Primitives, arrays, operators and control statements are ordinary and worth getting fluent in quickly. They are not where the difficulty is.

The difficulty is here. Constructor overloading and method overloading are the reliable early trap. Both mean several versions with the same name and different parameters. The difference is only that one is the thing that runs on creation. And this is what disambiguates when a parameter and a field share a name, which they very often do inside a constructor. Write both deliberately once, side by side, and the confusion does not form.

Objects as parameters and objects returned are the next step, and they behave as the memory module predicted. What is passed is a reference, so a method can change the object it was given.

Finally static and final. static means the member belongs to the class rather than to any object — there is one of it, however many objects exist. final means it cannot change, or in the case of a class, cannot be extended. Both are small words with large consequences for design.

What you should now be able to explain or do

State the four object-oriented ideas and say which later unit demonstrates each. Explain the shift from organising around actions to organising around things. Describe what a Java compiler produces and what runs it. Write classes with constructors, and keep constructor overloading and method overloading apart. Use this where a parameter shadows a field. Say what static and final each change.

Check yourself

Every later unit is one of them made concrete. Treated as vocabulary now, they arrive as a surprise later.

Bytecode, not machine instructions. A virtual machine executes the bytecode, which is what lets one build run on several platforms.

Only that one runs on creation. Both mean several versions sharing a name with different parameters, which is why they get confused.

Naming the object the method was called on, which is how you tell a field from a parameter that shadows it inside a constructor.

The member belongs to the class rather than to any object. There is exactly one of it, however many objects exist.

Go deeper

Back to Java Fundamentals, Classes & Objects: work through the checklist