0% found this document useful (0 votes)
5 views

Lecture-3 OOP-1

The document provides an overview of operators in Object Oriented Programming, specifically focusing on arithmetic, bitwise, relational, and logical operators. It explains the functionality of various operators, including examples of Bitwise OR and Bitwise AND operations. Additionally, it covers the types of variables such as local, instance, and static variables.

Uploaded by

Rajin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Lecture-3 OOP-1

The document provides an overview of operators in Object Oriented Programming, specifically focusing on arithmetic, bitwise, relational, and logical operators. It explains the functionality of various operators, including examples of Bitwise OR and Bitwise AND operations. Additionally, it covers the types of variables such as local, instance, and static variables.

Uploaded by

Rajin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

ICE 127: Object Oriented Programming

Credit Hour: 3
Lec - 3

Course Teacher
Md Istakiak Adnan Palash

Department of Information & Communication Engineering


Daffodil International University

Lec - 3 1
Operators

Lec - 3 2
Introduction
• Most of its operators can be divided into the following four
groups:
arithmetic,
bitwise,
relational, and
logical.

Lec - 3 3
Arithmetic Operators

Lec - 3 4
Arithmetic Operators
• The operands of the arithmetic operators must be of a numeric
type. You cannot use them on boolean types, but you can use
them on char types, since the char type in Java is, essentially, a
subset of int.

Lec - 3 5
Relational Operators

Lec - 3 6
The Bitwise Operators
• These operators act upon the individual bits of their operands.

Lec - 3 7
The Bitwise Logical Operators
• The bitwise logical operators are &, |, ^, and ~.

Lec - 3 8
Bitwise OR
Bitwise OR is a binary operator (operates on two operands). It's denoted by |.

The | operator compares corresponding bits of two operands. If either of the bits is 1,
it gives 1. If not, it gives 0. For example,

12 = 00001100 (In Binary)


25 = 00011001 (In Binary)

Bitwise OR Operation of 12 and 25


00001100
| 00011001
________
00011101 = 29 (In decimal)

Lec - 3 9
Example 1: Bitwise OR

Lec - 3 10
Bitwise AND
Bitwise AND is a binary operator (operates on two operands). It's denoted by &.
The & operator compares corresponding bits of two operands. If both bits are 1, it gives
1. If either of the bits is not 1, it gives 0.

For example,
12 = 00001100 (In Binary)
25 = 00011001 (In Binary)

Bit Operation of 12 and 25

00001100
& 00011001
________
00001000 = 8 (In decimal)

Lec - 3 11
Example 2: Bitwise AND

Lec - 3 12
Boolean Logical Operators
• The Boolean logical operators shown here operate only on boolean
operands. All of the binary logical operators combine two boolean
values to form a resultant boolean value.

Lec - 3 13
Boolean Logical Operators
• The logical Boolean operators, &, |, and ^, operate on boolean
values in the same way that they operate on the bits of an integer.

Lec - 3 14
Boolean Logical Operators

the string
representatio
n of a Java
boolean value
is one of the
literal values
true or false

Lec - 3 15
Conditional Operator ( ? : )
Conditional operator is also known as the ternary operator. This operator
consists of three operands and is used to evaluate Boolean expressions.
The goal of the operator is to decide which value should be assigned to the
variable. The operator is written as:

Lec - 3 16
Conditional Operator ( ? : )

Lec - 3 17
Variable
There are three types of variables: local, instance and static.
• Local Variable:
A variable that is declared inside the method is called local
variable.
• Instance Variable:
A variable that is declared inside the class but outside the
method is called instance variable . It is not declared as static.
• Static variable:
A variable that is declared as static is called static variable. It
cannot be local.

Lec - 3 18
Example

Lec - 3 19
Thank You

Lec - 3 20

You might also like