ICSE Class 10 Computer Applications Question 13 of 43

Conditional Constructs in Java — Question 13

Back to all questions
13
Question

Question 13

Rewrite the following statement using if else:

int max=215, min=323;
String str= (max>min) ? "Max is greater than Min" : "Min is Greater than Max";
Answer
int max=215, min=323;
String str="";
if (max > min)
  str = "Max is greater than Min";
else
  str = "Min is Greater than Max";