1.

What output will the following code fragment produceint val, Res, n=1000;Res=n+val>l750 ? 400 :200;System.out.println(res);(i) If the input is 2000.(ii) If the input is 500.

Answer»

As there is no statement of input is given in the question. Hence, it should be a tricky question. As by default when we declare an integer in Java, it stores the value 0(zero). 

Hence, the value of val=0. 

(i) Output: 200 

(ii) Output: 200



Discussion

No Comment Found

Related InterviewSolutions