Object Oriented Programming
Topic 1-2: Introduction to
Java Programming
Coding and Programming
Languages
Learning Outcomes
To successfully define:
• What is programming
• Programming languages
• Programming Paradigms
• Object Oriented Programming
Languages
•Language is a means of
communication, which
bridges barriers between
individuals and enables
exchange of ideas and
feelings.
•To communicate with each
other we use languages.
Languages (contd…)
Likewise, to communicate
with the computers, we use a
variety of languages known as
programming languages.
Programming
•The intention of this course is to teach you how to
program! You will learn how to give a computer a
sequence of instructions to perform a task.
•Learning a programming language isn’t difficult,
learning how to program is more difficult!
A formal set of
instructions to develop a
program to enable a
computer to perform a
What is a specific task or tasks.
programm
ing
language? A programming language
has a strict syntax or set of
rules that determine the
structure of the language.
What is a programming language?
We generally work with high level programming languages (Java /
Python) which are designed to be relatively human readable and logical
public class Main {
public static void main(String[] args) {
for (int i = 0; i < 10; i++) {
System.out.println(i);
}
}
}
for i in range(10):
print(i)
What is a Paradigm?
Think of a paradigm as a way of doing something or a style of
thinking.
Programmin
For example:
When cooking, some people follow a recipe step by step (like
g Paradigms baking a cake).
Others experiment and change things (like making their own
unique dish).
These are different ways of cooking.
What is a Programming Paradigm?
A programming paradigm is just a way of writing
code. It is like a cooking style but for programmers!
Programmin Why do we need different styles?
g Paradigms Some problems are easier to solve using one
style than another.
Different programming languages support
different styles.
Programming Paradigms
1. Procedural programming
2. Object-oriented programming
3. Functional programming
4. Event-driven programming
Object-Oriented Programming (OOP) is a popular way of writing
code because it helps us organize things better and make
programs easier to manage.
Why do OOP is Based on Objects
we use OOP structures code around objects. Think of an object as a real
thing in the world, like:
the OOP ✅ A car
paradigm? ✅ A mobile phone
✅ A student
Each object has properties (what it has) and actions (what it can
do).
Imagine a Car as an object in programming.
It has:
Example: 📌 Properties (Attributes):
Color = "Red"
A Car as Brand = "Toyota"
an Speed = 60 mph
Object
📌 Actions (Methods):
Start() → The car starts
Stop() → The car stops
Accelerate() → The car increases speed
🔹 Organizes code – Instead of writing everything
in one long list, we group related things together.
🔹 Reusability – We can create one object (like a
Why is Car) and make many copies (Toyota, BMW,
Honda).
OOP
Useful? 🔹 Easier to manage – If we need to update
something, we just change the object instead of
rewriting everything.
🔹 Models real-world things – We think in terms
of objects just like real life!
•Java is a strictly typed, object oriented language.
•Java’s structure and clarity make it an excellent
teaching language and it is used in many international
universities as one of the initial programming
Java
languages students are introduced to.
•Designed for portability (write once, run anywhere).
•Widely used for desktop, web and mobile
applications.
Java
•To develop in Java you will need
the latest version of the Java Language Initial release
date
Development Kit Standard Edition
(JDK SE). C# 2000
Python 1991
•Installing the JDK also ensures you
have the latest version of Java C++ 1985
installed for your development Java 1982
environment.
C 1972
•We use an Integrated Development
Environment to write Java code.
•IntelliJ is the environment we are using – it’s
What is an very powerful and at the same time very
helpful so it is worth using it extensively so
IDE? you gain a good understanding of all the tools
in IntelliJ.
•We will review the features of IntelliJ during
the programming labs
A class is like a blueprint or template for creating
objects.
Think of it as a design plan for building a house.
The plan tells us:
What the house will look like
What is a What features it will have (like doors, windows, and
rooms)
Class? But the plan itself is not a house. It’s just an idea of
how houses should be built.
In Java, a class defines:
Fields (Attributes) → These are the properties of the
object.
Methods (Functions) → These are the actions an
object can perform.
An object is an actual thing created from a
class.
Using the house blueprint, we can build many
What is houses.
Each house is an object, based on the same
an blueprint.
Example:
Object? A Car is a class.
A red Toyota and a blue BMW are objects.
Each object has its own values but follows the
same structure.
Key Points in the Image
🔹 Java uses classes throughout → Every Java program must
have a class.
🔹 Class names start with a capital letter → This is a Java rule.
🔹 main is a method → Java starts execution from here.
🔹 Java is case-sensitive → Main and main are not the same in
Java!
Key Points
and Simple
Explanatio
ns
What This Code Shows
✅ We created two objects (car1 and car2) from the same class Car.
✅ Each object has its own separate value for color.
✅ Even though both come from the Car class, they have different states.
Two circle
objects
Summary
• Object – Java objects model objects from a problem domain.
• Class – Objects are created from classes. The class describes the
kind of object; the objects represent individual instances of the
class.
• Method – We can communicate with objects by invoking methods
on them. Objects usually do something if we invoke a method.
Summary (Contd..)
• Parameter – Methods can have parameters to provide additional
information for a task.
• Multiple Instances – Many similar objects can be created from a
single class.
• State – Objects have state. The state is represented by storing
values in fields.
• Method Calling – Objects can communicate by calling each
other’s methods.