You are on page 1of 2

exercises chapter 2

Q 2.7
b.if
c. arithmetic
d. division and remainder
e.innermost
f.
Q 2.8
a. System.out.print("Enter an integer: ");
b. int a,b,c;
a=b*c;
c. //program to calculate payroll calculation
Q 2.9
a. False, all operators are evaluated left to right except the equal to operator
.
b. true.
c. true.
d. False, h22 is valid.
Q 2.10
a. x = 2
b. Value of 2 + 2 is 4
c. x=
d. 5= 5
Q.2.11
a. Value of p is modified
b. none
c. none, no variable present
d. Value of the variable value is modified.
Q 2.12
a,d,e are correct
Q 2.13
x = 7 + 3 * 6 / 2 - 1;
5 3 1 2 4
x = 2 % 2 + 2 * 2 - 2 / 2;
6 1 4 2 5 3
x = ( 3 * 9 * ( 3 + ( 9 * 3 / ( 3 ) ) ) );
4 5
3
1 2
Q 2.14
a. System.out.println("1 2 3 4");
b. System.out.print("1 ");
System.out.print("2 ");
System.out.print("3 ");
System.out.print("4 ");
c. System.out.printf("%d %d %d %d",1,2,3,4);
Q 2.15 , 2.16, 2.17, 2.18 in zip file
Q 2.24 to 2.35 also in zip file
Q 2.19

*
**
***
****
*****
Q2.20
*
***
*****
****
**
Q 2.21
**************
Q 2.22
****
*****
******
Q 2.23
*
***
*****