SlideShare a Scribd company logo
6/28/2019
Object Oriented 
Programming
Week 2
Ferdin Joe John Joseph
Thai‐Nichi Institute of Technology
Agenda
• Operators and Operands
• Control Statements
• If – else statement
Operators in Java
• Arithmetic Operators
• Relational Operators
• Logical Operators
• Bitwise Operators
• Assignment Operators
• Miscellaneous Operators
Arithmetic Opertors
Format
<operand1> <operator> <operand2> = result
6/28/2019
Arithmetic Operators
• + adds two operands C=A+B
• ‐subtracts second operand from the first C=A‐B
• * multiplies two operands C= A* B
• / divides numerator by de‐numerator C= A/B
• % modulus operator C=A%B
• ++ increment operator, increases integer value by one C=A++
• ‐‐decrement operator, decreases integer value by one C=A‐‐
Relational Operator
Format
<Operand1> <Operator> <Operand2>
Returns 0 or 1 as answer
Relational Operator
• == Checks if two values are equal A==B
• != Checks if two values are not equal A!=B
• > Checks if operand1 is greater than operand2 A>B
• < Checks if operand1 is lesser than operand2 A<B
• >= Checks if operand1 is equal to or greater than operand2 A>=B
• <= Checks if operand1 is equal to or lesser than operand2 A<=B
Logical Operator
• && Logical AND to check both operands are not zero A&&B
• || Logical OR to check any of the two operands is zero A||B
• ! Logical NOT operator to check if any logical operation is false 
!(A&&B)
6/28/2019
Bitwise Operators
• To do operations in binary level
• Converts integer from decimal to binary and then perform operation
Bitwise Operators
• & to do bitwise AND
• | to do bitwise OR
• ^ to do bitwise XOR
• ~  to do flipping of bits A = 60 = 0011 1100
• ~A = 1100 0011= 195
• << Binary left shift A = 0011 1100
• <<A = 1111 0000
• >> Binary right shift A = 00111100
• >>A = 0000 1111
Assignment Operators Expressions
• Anything whose evaluation yields a numeric value is an expression
• C=A+B, A+B is an expression whose evaluated value is stored in 
variable C
6/28/2019
Conditonal Constructs
• Provide Ability to control whether a statement list is executed
• Two constructs
If statement
• if
• if‐else
• if‐else‐if
• Switch statement
Basic if statement
• Syntax
• if(Expression)
Action
• If the Expression is true then execute Action
• Action
• is either a single statement 
• or a group of statements within braces
Example
if (Value < 0) {
Value = ‐Value;
}
Example – sorting of two numbers
int Value1,  Value2;
Value1=5;
Value2=10;
System.out.println(Value1 +” “+Value2);
if  (Value1  >  Value2)  
{
int RememberValue1  =  Value1;
Value1  =  Value2;
Value2  =  RememberValue1;
System.out.println(Value1 +” “+Value2);
}
6/28/2019
If – Else Statement
if(Expression)
Action 1
else
Action 2
• If  Expression is true then execute Action1
• otherwise execute  Action2
if (v == 0) {
System.out.println("v is 0“);
}
else {
System.out.println("v is not 0“);
}
Finding type of number
if ( nbr < 0 ){
System.out.println(nbr+" is negative“);
}
else if ( nbr > 0 ) {
System.out.println(nbr+" is positive“);
}
else {
System.out.println(nbr+" is zero“);
}
Nested if Next Week
• Looping
• For Loop
• While Loop
6/28/2019
Classwork
• Write java code to find whether the given year is a leap year or not
• Write java code to find whether the given number is odd or even

More Related Content

PPTX
Mathematical and logical operators
PPT
Arithmetic operator
PPTX
11operator in c#
PDF
Chapter 5 - Operators in C++
PPT
Operators in C++
PDF
C# Fundamentals - Basics of OOPS - Part 2
PPT
Operators and Expressions in C++
PPTX
Operator of C language
Mathematical and logical operators
Arithmetic operator
11operator in c#
Chapter 5 - Operators in C++
Operators in C++
C# Fundamentals - Basics of OOPS - Part 2
Operators and Expressions in C++
Operator of C language

What's hot (18)

PPTX
Csc240 -lecture_5
PPTX
PPTX
Cse lecture-4.1-c operators and expression
PDF
PPTX
OPERATORS OF C++
PDF
Coper in C
PPT
C operators
PPTX
Lecture 2 C++ | Variable Scope, Operators in c++
PPTX
Chapter 7: Arithmetic and Relational Operators
PPT
Types of operators in C
PPTX
Operator
ODP
operators in c++
PPTX
Operators in java script
PPTX
Increment and Decrement operators in C++
PPTX
PPTX
Functions in c++
PDF
8. operators
Csc240 -lecture_5
Cse lecture-4.1-c operators and expression
OPERATORS OF C++
Coper in C
C operators
Lecture 2 C++ | Variable Scope, Operators in c++
Chapter 7: Arithmetic and Relational Operators
Types of operators in C
Operator
operators in c++
Operators in java script
Increment and Decrement operators in C++
Functions in c++
8. operators
Ad

Similar to DSA 103 Object Oriented Programming :: Week 2 (20)

PPTX
Operators in C/C++
PPTX
Operators and Expressions
PDF
Operators in python
PPTX
Arithmetic and increment decrement Operator
PPTX
Operator in JAVA
PPTX
Operators Of C in C programming language
PPTX
intro to differnt oper.pptx
PPTX
PDF
Module2.1_Programming_Branching_and_looping.pdf
PDF
Constructor and destructors
PPTX
Operators in C#
PPTX
OPERATORS IN C.pptx
PPTX
ComputerProgrammingVarialblesanddeclaration.pptx
PPTX
What are operators?
PPTX
Oop using JAVA
PPTX
C Operators
PPTX
Ch4 Expressions
PPTX
C++ Programming Basics.pptx
PPTX
operat in vb .pptx
Operators in C/C++
Operators and Expressions
Operators in python
Arithmetic and increment decrement Operator
Operator in JAVA
Operators Of C in C programming language
intro to differnt oper.pptx
Module2.1_Programming_Branching_and_looping.pdf
Constructor and destructors
Operators in C#
OPERATORS IN C.pptx
ComputerProgrammingVarialblesanddeclaration.pptx
What are operators?
Oop using JAVA
C Operators
Ch4 Expressions
C++ Programming Basics.pptx
operat in vb .pptx
Ad

More from Ferdin Joe John Joseph PhD (20)

PDF
Invited Talk DGTiCon 2022
PDF
Week 12: Cloud AI- DSA 441 Cloud Computing
PDF
Week 11: Cloud Native- DSA 441 Cloud Computing
PDF
Week 10: Cloud Security- DSA 441 Cloud Computing
PDF
Week 9: Relational Database Service Alibaba Cloud- DSA 441 Cloud Computing
PDF
Week 7: Object Storage Service Alibaba Cloud- DSA 441 Cloud Computing
PDF
Week 6: Server Load Balancer and Auto Scaling Alibaba Cloud- DSA 441 Cloud Co...
PDF
Week 5: Elastic Compute Service (ECS) with Alibaba Cloud- DSA 441 Cloud Compu...
PDF
Week 4: Big Data and Hadoop in Alibaba Cloud - DSA 441 Cloud Computing
PDF
Week 3: Virtual Private Cloud, On Premise, IaaS, PaaS, SaaS - DSA 441 Cloud C...
PDF
Week 2: Virtualization and VM Ware - DSA 441 Cloud Computing
PDF
Week 1: Introduction to Cloud Computing - DSA 441 Cloud Computing
PDF
Sept 6 2021 BTech Artificial Intelligence and Data Science curriculum
PDF
Hadoop in Alibaba Cloud
PDF
Cloud Computing Essentials in Alibaba Cloud
PDF
Transforming deep into transformers – a computer vision approach
PDF
Week 11: Programming for Data Analysis
PDF
Week 10: Programming for Data Analysis
PDF
Week 9: Programming for Data Analysis
PDF
Week 8: Programming for Data Analysis
Invited Talk DGTiCon 2022
Week 12: Cloud AI- DSA 441 Cloud Computing
Week 11: Cloud Native- DSA 441 Cloud Computing
Week 10: Cloud Security- DSA 441 Cloud Computing
Week 9: Relational Database Service Alibaba Cloud- DSA 441 Cloud Computing
Week 7: Object Storage Service Alibaba Cloud- DSA 441 Cloud Computing
Week 6: Server Load Balancer and Auto Scaling Alibaba Cloud- DSA 441 Cloud Co...
Week 5: Elastic Compute Service (ECS) with Alibaba Cloud- DSA 441 Cloud Compu...
Week 4: Big Data and Hadoop in Alibaba Cloud - DSA 441 Cloud Computing
Week 3: Virtual Private Cloud, On Premise, IaaS, PaaS, SaaS - DSA 441 Cloud C...
Week 2: Virtualization and VM Ware - DSA 441 Cloud Computing
Week 1: Introduction to Cloud Computing - DSA 441 Cloud Computing
Sept 6 2021 BTech Artificial Intelligence and Data Science curriculum
Hadoop in Alibaba Cloud
Cloud Computing Essentials in Alibaba Cloud
Transforming deep into transformers – a computer vision approach
Week 11: Programming for Data Analysis
Week 10: Programming for Data Analysis
Week 9: Programming for Data Analysis
Week 8: Programming for Data Analysis

Recently uploaded (20)

PPT
Reliability_Chapter_ presentation 1221.5784
PDF
Recruitment and Placement PPT.pdfbjfibjdfbjfobj
PPTX
05. PRACTICAL GUIDE TO MICROSOFT EXCEL.pptx
PPT
Chapter 3 METAL JOINING.pptnnnnnnnnnnnnn
PDF
.pdf is not working space design for the following data for the following dat...
PPTX
IB Computer Science - Internal Assessment.pptx
PPTX
The THESIS FINAL-DEFENSE-PRESENTATION.pptx
PDF
22.Patil - Early prediction of Alzheimer’s disease using convolutional neural...
PDF
Mega Projects Data Mega Projects Data
PPTX
ALIMENTARY AND BILIARY CONDITIONS 3-1.pptx
PPTX
Introduction to Basics of Ethical Hacking and Penetration Testing -Unit No. 1...
PPTX
advance b rammar.pptxfdgdfgdfsgdfgsdgfdfgdfgsdfgdfgdfg
PPTX
Introduction-to-Cloud-ComputingFinal.pptx
PPTX
DISORDERS OF THE LIVER, GALLBLADDER AND PANCREASE (1).pptx
PDF
Launch Your Data Science Career in Kochi – 2025
PPTX
iec ppt-1 pptx icmr ppt on rehabilitation.pptx
PDF
BF and FI - Blockchain, fintech and Financial Innovation Lesson 2.pdf
PPTX
mbdjdhjjodule 5-1 rhfhhfjtjjhafbrhfnfbbfnb
PDF
Fluorescence-microscope_Botany_detailed content
Reliability_Chapter_ presentation 1221.5784
Recruitment and Placement PPT.pdfbjfibjdfbjfobj
05. PRACTICAL GUIDE TO MICROSOFT EXCEL.pptx
Chapter 3 METAL JOINING.pptnnnnnnnnnnnnn
.pdf is not working space design for the following data for the following dat...
IB Computer Science - Internal Assessment.pptx
The THESIS FINAL-DEFENSE-PRESENTATION.pptx
22.Patil - Early prediction of Alzheimer’s disease using convolutional neural...
Mega Projects Data Mega Projects Data
ALIMENTARY AND BILIARY CONDITIONS 3-1.pptx
Introduction to Basics of Ethical Hacking and Penetration Testing -Unit No. 1...
advance b rammar.pptxfdgdfgdfsgdfgsdgfdfgdfgsdfgdfgdfg
Introduction-to-Cloud-ComputingFinal.pptx
DISORDERS OF THE LIVER, GALLBLADDER AND PANCREASE (1).pptx
Launch Your Data Science Career in Kochi – 2025
iec ppt-1 pptx icmr ppt on rehabilitation.pptx
BF and FI - Blockchain, fintech and Financial Innovation Lesson 2.pdf
mbdjdhjjodule 5-1 rhfhhfjtjjhafbrhfnfbbfnb
Fluorescence-microscope_Botany_detailed content

DSA 103 Object Oriented Programming :: Week 2