Class 10 ICSE - Java

Class 10th Java aims to empower students by enabling them to build their own applications introducing some effective tools to enable them to enhance their knowledge, broaden horizons, foster creativity, improve the quality of work and increase efficiency.
It also develops logical and analytical thinking so that they can easily solve interactive programs. Students learn fundamental concepts of computing using object oriented approach in one computer language with a clear idea of ethical issues involved in the field of computing
Class 10th java topics includes revision of class 9th, constructors, user-defined methods, objects and classes, library classes , etc.

Iterative Constructs



Sometimes we want our programs to execute a few set of instructions over and over again.

For Example :
  • print numbers from 1 to 1000
  • print multiplication table of 7, etc.
Iteration make it easy for us to tell the computer that a given set of instructions need to be executed repeatedly.

Types of loop




Primarily there are three types of loops in java :

(i) While loop
(ii) do-while loop
(iii) for loop

while loop




  • The while loop in Java is used when we need to execute a block of code again and again based on a given boolean condition.

  • We use while loop when the exact number of iterations are not known to us.

  • If the condition never becomes false, the while loop keeps getting executed. Such a loop is known as an infinite loop.

  • It is also called as "entry control loop"

Syntax :



Example :

int i=10;

while(i>0){

System.out.println(i);

i--;

}


⇛ Flow control for while loop :





do-while loop




  • do-while loop is used to iterate a part of the program repeatedly, until the specified condition is true.

  • We use do-while loop when the exact number of iteration is not known to us and you want to execute the loop at least once.

  • do-while loop is executed at least once even if the condition is false.

  • It is also called as "exit control loop"

Syntax :



Example :

int i=1;

do{

System.out.println(i);

i++;

}while(i<=10);


⇛ Flow control for do-while loop :





for loop




  • For loop in java is used to iterate a block of code multiple times.

  • We use for loop only when the exact number of iterations are fixed

  • In for loop we can initialize the variable, check condition and increment/decrement value in one line.

Syntax :



Example :

for (i=7; i>0; i--)

{

System.out.println(i);

}


⇛ Flow control for do-while loop :





Jump Statements




⇛ Break Statement:

The break statement terminates the current loop. The execution continues from the statement immediately following the current loop. The break statement consists of the keyword break followed by a semicolon(;). Syntax :

break;


Program :



Output :



⇛ Continue Statement :

The continue statement in java instructs to escape the rest of the current iteration of the loop and it jumps back to the beginning of the loop and continues with the next iteration. The continue statement consists of the keyword continue followed by a semicolon(;). Syntax :

continue;


Program :



Output :



Contact Us

REACH US

SERVICES

  • CODING
  • ON-LINE PREPARATION
  • JAVA & PYTHON

ADDRESS

B-54, Krishna Bhawan, Parag Narain Road, Near Butler Palace Colony Lucknow
Contact:+ 919839520987
Email:info@alexsir.com