what will be output when :a) Val =500 b) Val =1500 Int Val, sum, n=550.sum=n+val >1750?400:200System.out.println(sum),
Answers
Answered by
4
Ans :- (a) 200 (b) 400
a) Val = 500
int Val=500, sum,n=550;
sum = n+val>1750?400:200 ....(line 2)
sum = 200
{
Explaination
n = 550, Val=500,n+Val=1050
n+Val>1750 (false)
sum= 200 because line 2 contains ternary
operator.
In that case before question mark is the
condition ( n+val>1750) and if condition is
true the value after ? will be use(400) else
200 will be use.
}
a) Val = 500
int Val=500, sum,n=550;
sum = n+val>1750?400:200 ....(line 2)
sum = 200
{
Explaination
n = 550, Val=500,n+Val=1050
n+Val>1750 (false)
sum= 200 because line 2 contains ternary
operator.
In that case before question mark is the
condition ( n+val>1750) and if condition is
true the value after ? will be use(400) else
200 will be use.
}
Answered by
2
200 will be used ok
PLEASE MARK AS BRAINLIST
Similar questions
Math,
8 months ago
Sociology,
8 months ago
World Languages,
8 months ago
Hindi,
1 year ago
Math,
1 year ago
Math,
1 year ago
Sociology,
1 year ago
Accountancy,
1 year ago