5. Identifiers are the names given to elements like class , methods,
variables etc.
Rules
1. Variable name must begin with a letter, a doller symbol or an
under Score, which can be followed by a sequence of letters or
digits or, $ or _
2. It must be unique
3. It can be of any length
4. There should not be any space in between
5. Key words cannot be used
6. Java is case sensitive
6. Decimal(10) ex 23,-34,0, 1234
Octal (8) ex 023,034
Hexa Decimal(16) ex OX23,OX34
Standard Example 2.4double , 3.5FFloat
Scientific Example 2.4E7, 56e5
true or false
‘a’,’B’,’t’,’u0064’Hexa,’141’octal
“nihar Ranjan Roy”
9. Positive number right shift
13>>1
13(1101)2
0000 1101 shift by 1 place
0000 01106
Positive number left shift
13<<1
0000 1101
0001 101026
Trick no/2n
13/21=13/2=6
Trick 2n*no
check 21*13=26
10. Negative number right shift
-10>>2
-10<<2
100000 1010
-10?
Rule Change 01 and 10 for all bits except the right most
bit that starts with 1
-101111 0110
-10>>21111 1101=-3
-10<<21101 1000=-40
Trick
-10/2n=-10/4=-2.5= -3
-10*2n=10*4=-40
11. 100000 1010
-101111 0110
It does not distinguish between + and –ve numbers
10>>>2=0000 0010=2
-10>>>2
00111111 11111111 11111111 11111111=1073741821
Conclusion it places 0’s at MSB
12. Write a program in java that finds the sum of
the digits of an integer number till the sum
comes to single digit
Note D0not use any Loop
Example
12345=1+2+3+4+5=15=1+5=6
15. Statement Keywords
Decision Making if , if else, switch
Loop for , while, do while
Exception try, catch, finally
Miscellaneous( others) break, continue ,return,
label
16. Switch If else
It can test only equality It evaluates any type of
Boolean expression
Break is needed Break is not needed
More efficient way of
represent branching
Less efficient way
It is faster Its slower
U cannot use a range of
values easily
U can use range of
values
17. Causes the flow to exit from the loop
…….
for ( int I =0;i<5;i++)
{
If (i==3)
break;
}
……..
Int i=6;
one:
{
System.out.println(“inside one”);
two:
{
System.out.println(“inside one”);
if (i==3)
break one;
}
}
19. A frog starts climbing 30 ft well. Each hour frog
climbs 3ft and slips back 2ft. How many hours
does it take to reach top and get out?
[Hint: if Height>30 break;]
20. [Hint: sum of cubes of individual digits
give same number.
153=13+53+33=1+125+27=153]
Write a java program to find the
Armstrong number from 100 to 1000