Fundamentals of Programming - Week 3-4-5
Fundamentals of Programming - Week 3-4-5
AND OBJECT-
ORIENTED
PROGRAMMIN
FUNDAMENTALS OF PROGRAMMING
College of Computing and Information Technolo
Procedural Programming
Procedural Programming can be defined as a programming model
which is derived from structured programming, based upon the
concept of calling procedure. Procedures, also known as routines,
subroutines or functions, simply consist of a series of computational
steps to be carried out. During a program’s execution, any given
procedure might be called at any point, including by other
procedures or itself.
bject-Oriented Programming
Object-oriented programming can be defined as a programming
model which is based upon the concept of objects. Objects contain
data in the form of attributes and code in the form of methods. In
object-oriented programming, computer programs are designed using
the concept of objects that interact with the real world. Object-
oriented programming languages are various but the most popular
ones are class-based, meaning that objects are instances of classes,
which also determine their types.
cedural & Object-Oriented Programming
ample Procedural Programming
Sample
Object-
Oriented
Programming
OBJECTS AND
CLASSES IN
JAVA
FUNDAMENTALS OF PROGRAMMING
College of Computing and Information Technolo
What is an Object in Java?
An entity that has state and
behavior is known as an object
e.g., chair, bike, marker, pen, table,
car, etc. It can be physical or logical
(tangible and intangible). The
example of an intangible object is
the banking system.
hree characteristics of Objects
Objects in Java
For Example, Pen is an object. Its name is Reynolds; color is white,
known as its state. It is used to write, so writing is its behavior.
Object Definitions:
• An object is a real-world entity.
• An object is a runtime entity.
• The object is an entity which has state and behavior.
• The object is an instance of a class.
What is a Class in Java?
A class is a group of objects which have common properties. It is a
template or blueprint from which objects are created. It is a logical
entity. It can't be physical.
• Fields
• Methods
• Constructors
• Blocks
• Nested class and interface
mple Code for Class and Object
We can also create multiple objects and
store information in it through reference
variable.
BASIC
OPERATORS IN
JAVA
FUNDAMENTALS OF PROGRAMMING
College of Computing and Information Technolo
ARITHMETIC
OPERATORS
Operator Use Description
+ op1 + op2 Adds op1 and op2; also used to concatenate strings
- op1 - op2 Subtracts op2 from op1
* op1 * op2 Multiplies op1 by op2
/ op1 / op2 Divides op1 by op2
% op1 % op2 Computes the remainder of dividing op1 by op2
The Java programming language supports various arithmetic operators for all
floating-point and integer numbers. These operators are + (addition), -
(subtraction), * (multiplication), / (division), and % (modulo).
RELATIONAL
OPERATORS
Operator Description Example
NOT OPERATOR
Con Result
T F
F T
UNARY
OPERATORS
Operator Meaning
++ Increment operator: increments value by 1
-- Decrement operator: decrements value by 1
LIMIT
DECIMAL
PLACES IN
JAVA
FUNDAMENTALS OF PROGRAMMING
College of Computing and Information Technolo
Using .format()
Using .format()