Wednesday, 27 February 2013

Class 9 Revision

Jumping statement :
i) break : This statement is used to transfer the execution flow outside the loop body.
int x=5,i=1;
while(i<=10)
{
System.out.println(i);
i++;
 if (i==x)
break;
}
The output will be:
1
2
3
4

ii ) continue :This statement changes the flow of execution to stop the current iteration and moves to the next iteration.

int x=5,i=0;
while(i<=10)
{
++i ;
 if (i==x)
continue;

else
System.out.println(i);

}

The output will be:1
2
3
4
6
7
8
9
10
11Java Expressions :
i)  

x3+y2  
Math.pow(x,3) + Math.pow(y,2)
 Output :i ) a - (b++) *  (-- c) if a=2, b=3 and c= 9

ans = - 22
Comments :
It is ignored by the compiler, it is used to state the purpose of the instructions in the program.
 // for single line comment.
/*       */  for multiple line comment.
Escape Sequence :
Non printable characters.
\a bell
\b backspace
\f form feed
\r carriage return
\v vertical tab
\t horizontzl tab
\n new line

Data types:
i) Primitive data type: byte,short,int, long,float, double,, char, boolean
ii ) Reference data type: arrays,classes