Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Class notes

Java Notes | OOP Concepts in Java with Examples | Beginner Friendly

Rating
-
Sold
-
Pages
34
Uploaded on
23-06-2025
Written in
2024/2025

These are comprehensive Java Programming Notes focused on Object-Oriented Programming (OOP) concepts. Perfect for beginners and BCA/B.Tech students. This PDF explains key topics like: 1. Object, Class, Inheritance, Polymorphism, Abstraction & Encapsulation 2. Java vs C++ comparison 3. Java program structure (syntax, main method, packages, comments, etc.) 4. JVM, JDK, JRE architecture 5. Extra concepts: Coupling, Cohesion, Aggregation, Composition, Command-line arguments 6. Clear examples and simple explanation. 7. Ideal for university exams, assignments or interview preparation . These notes are well-structured and easy to revise quickly.

Show more Read less
Institution
Course

Content preview

JAVA PROGRAMMING
Unit I


Object-Oriented Programming
Overview

OOPs or Object-Oriented Programming is a programming approach that centers on organizing a program
around its data and well-defined interfaces, with the aim of making code more closely aligned with the
real world. This is achieved by using objects in a programming language.

The main purpose of OOPs programming is to implement ideas and solve real-world problems
using classes, objects, inheritance, polymorphism, and abstraction. Some of the most
popular OOP languages include Java, C++, and Python.

OOPs can be defined as:

A modular approach where data and functions can be combined into a single unit known as an object. It
emphasizes data and security and provides the reusability of code. Using OOP, we can resemble our code
in the real world.

List of Java OOPs Concepts

The following are the concepts in OOPs :

 Object

 Class

 Inheritance

 Polymorphism

 Abstraction

 Encapsulation




What is Class in Java OOPs?

A Class is a collection of similar types of objects. It is commonly known as the 'blueprint of an object'. It
is a template that describes the kinds of state and behavior that the object of its type support.

 Class is a user-defined data type. Also, it doesn't occupy any memory.

,  It is composed of name, attributes, and methods. Access
Modifiers(public, private, default, protected) are used for having limited or public access to that
class so that it can be used by other programs in Java.

 We create individual objects using class.



In our example, we can create a class known as "Plane" which will be its name. It consists of the
attributes/fields and methods that each plane will have.

We can have the following attributes :

 plane_number

 total_seats

 airline_class

 pilot_name

Our "Plane" class can contain the following methods to use the above attributes

 seatAvailability()- this checks how many seats are available or vacant on that plane.

 selectClass()- lets you choose the class in which you want to travel- eg. business class or
economy class.

In short, the "Plane" class is a blueprint that represents a plane in a flight management system and we
have to create it to represent a real-world entity.

Syntax:

public class Plane {

//attributes

//methods

}

But before diving deeper into the sea of OOPs, let us get acquainted with some terminologies.

Member Functions- The functions are written inside a class are known as member functions.

Instance variables- Variables that are declared within the scope of the class.



What is an Object in Java OOPs?

As we have discussed above, Objects are the building blocks of OOP. A Java program is mostly a
collection of objects talking to other objects by invoking each other’s method.

,At a run time, when JVM encounters the “new” keyword, it will use the appropriate class o make an
object which is an instance of that class. That object will have its state and access to all of the behavior
defined by the class.

 Objects are real-world entities which have a certain state and behavior.

 Objects are commonly known as an 'instance of a class'.

 In our example, we created the class "Plane". So now, we will create objects from the same class.
Each object will have the attributes and methods defined in the class. If we want to create an
object of class "Plane" , we use the following syntax.



Syntax:

Plane P1 = new Plane();

So this P1 object will contain its characteristics like its number, total seats, plane class(business,
economy, etc.), and pilot. Creating another object of class "Plane" will give it all the attributes that were
defined in that class.

 Objects interact with each other and share information. This technique is termed Message
Passing.

 Objects are allocated memory space and address too.

The following figure illustrates the relationship between objects and classes.



The figure shows that the class Plane acts as a template to create objects which contain the attributes of
the class(Plane).

Four Pillars of OOPs in Java

The following are the basic principles of OOP in Java. They are known as the principles as the entire OOP
lays its foundation on these principles.

 Inheritance

 Polymorphism

 Abstraction

 Encapsulation

An easy way to remember OOPs principle is by remembering the sentence- I ate A
PIE.(Abstraction, Polymorphism, Inheritance, Encapsulation)

What is Inheritance in Java OOPs?

, Inheritance is a mechanism of deriving one class from another. It allows the derived class to inherit
features from a parent class, the features include (fields and methods). The parent class is also known as
the superclass or base whereas the derived class is known as a subclass or child class.

 Inheritance is a property of OOPs in which member functions and data members of one class can
be used by another class.

 Reusability of code can be achieved because of inheritance. If we want to create a class that
already has some common methods which we want to define within another class, we can use
the already existing class as a base class or a parent class and then inherit from it.

 Hence the code can be reused as we don't need to write the same piece of code again and can
use it in the derived class or child class.

 Base class- a class from which member functions and data members are used by another class.

 Derived class- a class that uses the properties of the base class and can also add its properties.

In our example, we created a class "Plane" which contained attributes like plane_number, total_seats,
airline_class, and pilot_name. All the planes are of the sub-type of class "Plane" and they have common
attributes mentioned above.

So in addition planes have their distinct attributes like luxury_arrangements, food, and air hostess. So
instead of defining the common properties again, we can only define the distinct properties in the new
class and inherit the common properties from the base class.

Types of Inheritance :

 Single

 Multilevel

 Hybrid

 Hierarchical

The above image shows various inheritances and their syntax.

What is Polymorphism in Java OOPs?

As the name suggests, it means many forms. It is the ability to create a function, variable, or an
object that has more than 1 form. The concept of polymorphism is expressed by 'one interface, many
methods'. It is one of the Principles of OOPs.

Two types of polymorphism in java :

 Compile-time : It is also known as static or early binding. The binding is performed during
compilation time.

 Run time : It is also known as dynamic or late binding. The binding occurs during runtime,
depending on the type of object.

The two types of polymorphism are achieved in java by :

Written for

Institution
Course

Document information

Uploaded on
June 23, 2025
Number of pages
34
Written in
2024/2025
Type
Class notes
Professor(s)
Not specific
Contains
All classes

Subjects

$4.48
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
siddiquiansa66

Get to know the seller

Seller avatar
siddiquiansa66 Mauj
Follow You need to be logged in order to follow users or courses
Sold
1
Member since
1 year
Number of followers
0
Documents
2
Last sold
10 months ago

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions