1.

Predict the output of the following snippets. (2)val = 1600; int val, sum, n=550; sum=n+val>1750?400:200; System.out.println(sum);​

Answer»

Question:-

int val = 1600;

int sum, n=550;

sum=n+val>1750?400:200;

System.out.println(sum);

_____________________

Output:-

400

_______________________

Answer with Explaination:-

Initially, val =1600 and n=550

sum=n+val>1750?400:200;

n+val=1600+550=2150

So, 2150 >1750.....True

So,sum will GET 400

Hence the correct output is 400.



Discussion

No Comment Found