Introduction to Java and OOPS

Java 10 min min read Updated: Mar 30, 2026 Beginner
Introduction to Java and OOPS
Beginner Topic 1 of 25

Introduction to Java and OOPS

Java is one of the most popular and widely used programming languages in the world. It is used for enterprise applications, backend systems, Android apps, desktop applications, and large-scale web platforms. One of the biggest reasons behind Java’s popularity is its platform independence and strong support for Object-Oriented Programming, commonly called OOPS.

When students start learning Java, the first step is understanding what Java is, how Java programs run, and why OOPS is considered such an important concept in software development. This topic builds the base for everything that comes later in Core Java.

Key Concept: Java is a platform-independent, object-oriented programming language, and OOPS helps developers write modular, reusable, and maintainable code.

What is Java?

Java is a high-level, object-oriented, class-based programming language developed by Sun Microsystems and later maintained by Oracle. It was designed to be simple, secure, portable, and robust.

The most famous idea behind Java is:

Write Once, Run Anywhere (WORA)

This means a Java program can be written once and run on multiple platforms such as Windows, Linux, and macOS without changing the source code, as long as a Java Virtual Machine (JVM) is available on that system.

Why Java is Platform Independent

In many traditional programming languages, source code is compiled directly into machine code, and that machine code is tied to a specific operating system or processor architecture. Java works differently.

  • The source code is written in a .java file
  • The Java compiler converts it into bytecode
  • That bytecode is stored in a .class file
  • The JVM reads and executes the bytecode on any supported platform

Because the bytecode is not tied to a single operating system, Java programs are portable across platforms.

Java Program Execution Flow

To understand Java properly, it is important to know how a Java program is written, compiled, and executed.

Step 1: Write the Source Code

A Java program is written in a file with the .java extension.

text Hello.java

Step 2: Compile the Program

The Java compiler javac converts the source code into bytecode.

bash javac Hello.java

After compilation, a new file is created:

text Hello.class

Step 3: Run the Program

The bytecode is executed using the JVM.

bash java Hello

This process makes Java both compiled and interpreted in nature. The code is first compiled into bytecode, and then the JVM interprets or executes that bytecode.

Important Java Components

JDK

JDK stands for Java Development Kit. It includes everything required to develop Java programs, such as the compiler, runtime, and development tools.

JRE

JRE stands for Java Runtime Environment. It provides the environment needed to run Java applications.

JVM

JVM stands for Java Virtual Machine. It is the engine that executes Java bytecode.

Remember: JDK is used to develop Java applications, JRE is used to run them, and JVM is the actual engine that executes bytecode.

First Java Program

Let us look at the simplest Java program.

java class Hello { public static void main(String[] args) { System.out.println("Hello, Java!"); } }

Output

text Hello, Java!

Understanding the First Program

1. class Hello

This declares a class named Hello. In Java, every program is written inside a class.

2. public static void main(String[] args)

This is the main method, which acts as the entry point of the Java program. When the program runs, JVM first looks for this method.

  • public means the method can be accessed from anywhere
  • static means the method belongs to the class, not to an object
  • void means the method does not return any value
  • main is the predefined method name that JVM recognizes
  • String[] args stores command-line arguments

3. System.out.println()

This statement prints the given text to the console.

What is OOPS?

OOPS stands for Object-Oriented Programming System. It is a programming approach in which programs are designed around objects rather than only functions and procedures.

In OOPS, real-world entities are modeled in code using:

  • Classes
  • Objects
  • Properties
  • Methods

This makes programs more organized, reusable, and easier to maintain.

Real-World Understanding of OOPS

Consider a real-world object like a Car.

  • Properties: color, brand, model, speed
  • Behaviors: start(), stop(), accelerate()

In Java, we represent such real-world things using classes and objects.

What is a Class?

A class is a blueprint, template, or design for creating objects. It defines what data an object will have and what actions it can perform.

java class Car { String color; String brand; void start() { System.out.println("Car started"); } }

In the above example:

  • color and brand are properties
  • start() is a behavior or method

What is an Object?

An object is a real instance of a class. When an object is created, memory is allocated, and it can use the variables and methods defined in the class.

java public class Main { public static void main(String[] args) { Car c1 = new Car(); c1.color = "Red"; c1.brand = "Toyota"; c1.start(); System.out.println(c1.color); System.out.println(c1.brand); } }

Output

text Car started Red Toyota

Understanding Class and Object with Simple Explanation

Think of a class as the design of a house and the object as the actual built house.

  • A class does not occupy memory for actual data until an object is created
  • An object is the actual usable entity

Why OOPS is Important in Programming

OOPS is important because real software projects are large and complex. Writing everything as simple instructions becomes difficult to manage. OOPS solves this problem by organizing code into meaningful units.

  • Reusability: code can be reused through classes and inheritance
  • Maintainability: changes become easier
  • Scalability: large projects become manageable
  • Real-world modeling: business objects can be represented clearly

Four Main Pillars of OOPS

The four pillars of object-oriented programming are:

  • Encapsulation
  • Inheritance
  • Polymorphism
  • Abstraction

1. Encapsulation

Encapsulation means wrapping data and methods together into a single unit and controlling direct access to data.

For example, in banking software, account balance should not be directly modified by anyone. Instead, it should be accessed through controlled methods.

java class Account { private double balance; public void setBalance(double balance) { this.balance = balance; } public double getBalance() { return balance; } }

Here, balance is private, so it cannot be accessed directly from outside the class. This improves security and control.

2. Inheritance

Inheritance allows one class to acquire the properties and methods of another class.

It supports code reuse and helps create logical class hierarchies.

java class Animal { void eat() { System.out.println("Animal is eating"); } } class Dog extends Animal { void bark() { System.out.println("Dog is barking"); } }

In this example, Dog inherits the eat() method from Animal.

java public class Main { public static void main(String[] args) { Dog d = new Dog(); d.eat(); d.bark(); } }

Output

text Animal is eating Dog is barking

3. Polymorphism

Polymorphism means one method or one interface can behave differently in different situations.

One common example is method overloading.

java class MathOperation { int add(int a, int b) { return a + b; } int add(int a, int b, int c) { return a + b + c; } }

The method name add is the same, but the parameters are different. This is called compile-time polymorphism.

4. Abstraction

Abstraction means showing only the essential details and hiding the internal implementation.

For example, when you drive a car, you use the steering wheel, brake, and accelerator. You do not need to know the full internal engine mechanism while driving.

java abstract class Vehicle { abstract void start(); } class Car extends Vehicle { void start() { System.out.println("Car starts with key"); } }

Here, the user only knows that start() exists. The internal implementation is hidden.

Difference Between Class and Object

Class Object
Blueprint or template Instance of a class
Logical entity Physical entity
No actual memory for instance data Consumes memory when created
Defines properties and methods Uses those properties and methods

Java Features

  • Simple: Java syntax is easier than many low-level languages
  • Object-Oriented: Java uses class and object-based design
  • Platform Independent: Java runs through JVM
  • Secure: Java avoids unsafe memory operations
  • Robust: Java includes exception handling and memory management
  • Multithreaded: Java supports concurrent execution
  • Portable: Java programs can run on different systems

Real-World Example: Student Class

Let us take another simple example to make the concept clearer.

java class Student { String name; int age; void study() { System.out.println(name + " is studying"); } } public class Main { public static void main(String[] args) { Student s1 = new Student(); s1.name = "Amit"; s1.age = 20; Student s2 = new Student(); s2.name = "Riya"; s2.age = 22; s1.study(); s2.study(); } }

Output

text Amit is studying Riya is studying

In this example, both s1 and s2 are different objects created from the same Student class.

Common Beginner Mistakes

  • Thinking class and object are the same thing
  • Forgetting that Java code always runs through JVM
  • Assuming OOPS is only theory and not useful in real projects
  • Trying to access private data members directly

Interview-Oriented Points

  • Java is platform independent because of bytecode and JVM
  • Java is both compiled and interpreted
  • OOPS helps in modular, reusable, and maintainable design
  • The four pillars of OOPS are encapsulation, inheritance, polymorphism, and abstraction

Conclusion

Java is a powerful language designed for portability, security, and maintainability. Understanding the basics of Java and OOPS is the first major step in becoming a strong Java developer.

Once you understand class, object, JVM, and the four pillars of OOPS, the remaining Core Java topics become much easier to understand because they are all built on this foundation.

Quick Summary: Java is a platform-independent programming language, and OOPS is the design approach that helps developers model real-world entities using classes and objects.

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators