Rewrite the following program segment using if-else statement [2]
tax=(income>20000)?income*0.20:0
(v)What will be the output of the following program segement? [2]
int i=1;
While(++i<=1)
{
i++;
}
System.out.println(i);
(vi)Evaluate the following java Expression [3]
Int a=2,b=3,c;
c=a++ + b++ + a%b
System.out.print(a+” ”+b+” ”+c);
Answers
Answered by
2
I. if (income > 20000)
tax = income * 0.20f;
else tax = 0;
II. 2.
III. 3 4 8
As,
> c = a++ + b++ + a % b;
> c = 2 + 3 + 3 % 4, a = 3, b = 4
> c = 5 + 3
> c = 8, a = 3, b = 4.
Similar questions