More Related Content
PPTX
Control statements in java PPTX
PPT
05. Control Structures.ppt PPTX
Lecture - 5 Control Statement PPTX
Unit-02 Selection, Mathematical Functions and loops.pptx PPT
PPTX
PPT
4.CONTROL STATEMENTS_MB.ppt . Similar to Object Oriented Programming Chapter IV.ppt
PPT
PDF
PPTX
controlStatement.pptx, CONTROL STATEMENTS IN JAVA PPTX
PDF
PPT
PDF
Control structures in Java PPTX
Chapter-9 viruses in infected system.pptx PPTX
Control Statements in Java PPTX
Computer programming 2 Lesson 8 PPTX
Programming in java - Concepts- Operators- Control statements-Expressions PPTX
Chapter 2 : Programming with Java Statements PPTX
PPT
Loops Do While Arduino Programming Robotics PPTX
Control flow statements in java PPTX
OCA JAVA - 2 Programming with Java Statements PPT
_Java__Expressions__and__FlowControl.ppt PPTX
PPTX
PDF
csj-161127083146power point presentation More from MNATARAJASURESH
PPTX
Object_Oriented_Design_Class and Object Diagrams.pptx PPTX
Object_Oriented_Design_Basic Behavioral Modeling.pptx PDF
Decision Trees in Artificial Intelligence.pdf PPTX
Artificial Intelligence - Unit - III.pptx PPTX
OOAD____Advanced Structural Modeling.pptx PPTX
OOAD_Advanced Structural Modeling - 2.pptx PPTX
Artificial Intelligence Unit - II_ JNTUA R23 regulations.pptx PPTX
Artificial Intelligence - Unit - IV.pptx PDF
ArtificialIntelligence_rule-based-deduction-systems.pdf PPTX
OOAD___Advanced Behavioral Modeling.pptx PPTX
JNTUA R23 regulations AI Unit-I PPT.pptx PPTX
ArtificialIntelligence_Skolemization.pptx PPTX
Object_Oriented_Design_Architectural Modeling.pptx Recently uploaded
PPTX
Keeping the Home Fires Burning - How cesium formate brine has helped to keep ... PPTX
Lean Maintenance: Streamlining Operations for Efficiency & Reliability PPTX
Avoiding Pitfalls: The 7 Biggest Maintenance Mistakes Plant Managers Make PPTX
Preventive Maintenance for Material Handling Equipment — Complete Guide PDF
Ground heat exchanger for rootzone cooling of crops in vertical aeroponics PDF
Presentation-on-Energy-Transition-in-Bangladesh-Employment-and-Skills.pdf PPTX
Importance of Asset Register in Maintenance Management PPT
Pointer in C: declaration and initialization PPTX
Technology Stack Evolution: Analyzing Programming Language & Database Trends ... PPTX
Coupled Hazard-Mobility Framework for Optimizing Emergency Vehicle Routing PDF
STOP CONSOLIDATION: Optimizing Transit Speed & Rider Experience PPT
861828706-chapter-7 introductionto UrbanHydrology.ppt PPT
Theory Of Computation-viruses Theory Of Computation-viruses PPTX
firewall Selection in production life pptx PPTX
DEEP LEARNING UNIT 2 all about deep learning PPTX
Lecture-15- Thermodynamics II Mohamed salem-NO COMMENTARY.pptx PDF
Albert Pintoy - Specializing In Low-Latency PPTX
Assessment 4 SRS Presentation - Final (2).pptx PPTX
UnrealGameplayAbilitySystemPresentation.pptx PPTX
MECCA Empire – Hotel Shuttle System for the 2026 FIFA World Cup Object Oriented Programming Chapter IV.ppt
- 1.
- 2.
- 3.
Selection statements: Thesestatements give an option of choosing
different paths of execution of a program depending on the result of a
test condition.
•The expressions in this group are if, if–else, and switch statement.
Iteration statements: These statements allow repeated evaluation of a
statement or a block of statements if the test condition is satisfied.
•This group contains statements such as while, do–while, for, and for–
each.
Control Statements
© Oxford University Press 2018. All rights reserved.
- 4.
Jump statements: Thesestatements make the program control jump
to another part of a program in the forward or backward directions
with or without a test condition.
•The statements in this group are break, break label, continue,
continue label, and return.
Control Statements
© Oxford University Press 2018. All rights reserved.
- 5.
• The codefor if statement is as follows:
if (conditional expression)
statement;
if Expression
© Oxford University Press 2018. All rights reserved.
- 6.
- 7.
- 8.
- 9.
- 10.
• The codefor if –else statement is as:
if (expression)
{/* statements */}
else {/* statements */}
If-else Expressions
© Oxford University Press 2018. All rights reserved.
- 11.
- 12.
• The codefor if statement is as follows:
if (conditional expression)
statement;
Program Example
© Oxford University Press 2018. All rights reserved.
- 13.
- 14.
• Its codeis as follows:
Expression1 ?Expression2 :Expression3
• The first expression is the test condition.
• If it evaluates true, the Expression2 is executed; otherwise
Expession3 is executed.
Ternary Operator ?:
© Oxford University Press 2018. All rights reserved.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
• Iteration orlooping refers to repetitive evaluation of a statement or
a block of statements in order to get the final output.
• Java has the following constructs for looping:
(i) while (Expression)
(ii) do
--------
while (Expression);
(iii) for ( Expressions)
Iteration Switch Statement
© Oxford University Press 2018. All rights reserved.
- 22.
• The whileloop may be coded as:
while (test expression)
statement;
• If the while test expression evaluates true, the statement following
the expression is executed.
while Expression
© Oxford University Press 2018. All rights reserved.
- 23.
- 24.
- 25.
• The endlesswhile loop may be coded as:
while (true)
• However, it can be stopped by break statement, which is coded as :
break;
Endless while Loop
© Oxford University Press 2018. All rights reserved.
- 26.
- 27.
• This loopis similar to while loop except for the fact that the test
expression is placed at the end.
• The statement to be executed is placed between do and while
expression.
Code is:
do
Statement;
while (test expression);
do while Loop
© Oxford University Press 2018. All rights reserved.
- 28.
- 29.
The code forif statement is as follows:
if (conditional expression)
statement;
Program Example
© Oxford University Press 2018. All rights reserved.
- 30.
• The forloop is the most versatile loop when the start and end points
of the loop are known.
• It is an entry controlled loop
for (initialization; test expression; Iteration)
Statement;
for Loop
© Oxford University Press 2018. All rights reserved.
- 31.
- 32.
- 33.
- 34.
• The for–eachloop is also called enhanced for loop.
• It was introduced in Java 5 to simplify the iteration through arrays
and collections. The general form of the loop is
for(Object obj:Collection_name){Body of loop}
A
For-Each for Loop
© Oxford University Press 2018. All rights reserved.
- 35.
- 36.
- 37.
Advantages:
1. Less clutterin code, especially when iterators are used.
2. Less chances of errors.
3. Improves overall readability of program.
Advantages and Limitations of for–each Loop
© Oxford University Press 2018. All rights reserved.
- 38.
Limitations:
1. It isdesigned to iterate in forward direction only.
2. In iteration, it takes a single step at a time.
3. It cannot simultaneously traverse multiple arrays or collections.
Advantages and Limitations of for–each Loop
© Oxford University Press 2018. All rights reserved.
- 39.
- 40.
• This isused for exiting from a loop and control goes to the end of
the current loop.
Break Statement
© Oxford University Press 2018. All rights reserved.
- 41.
- 42.
• Break witha label statement is similar to goto statement in C++,
but the implementation is different.
Break Statement with Labels
© Oxford University Press 2018. All rights reserved.
- 43.
- 44.
The statement continueis used to shift the control to the test
expression and would skip the processing of the remaining statements.
Continue Statement
© Oxford University Press 2018. All rights reserved.
- 45.
- 46.
- 47.
- 48.