Which of these is the output of the following program?int grade = 4;if(grade > 5) { System.out.println("Added water.");}else if(grade > 3) { System.out.println("Added soda.");}if(grade > 3) { System.out.println("Added ice");}if(grade > 2) { System.out.println("Added straw.");}if(grade <= 2) { System.out.println("Added lemon."); }Added soda.Added ice.Added straw.Added water.Added soda.Added ice.Added straw.Added water.Added ice.Added straw.Added water.Added soda.Added ice.Added straw.Added lemon.
Question
Which of these is the output of the following program?int grade = 4;if(grade > 5) { System.out.println("Added water.");}else if(grade > 3) { System.out.println("Added soda.");}if(grade > 3) { System.out.println("Added ice");}if(grade > 2) { System.out.println("Added straw.");}if(grade <= 2) { System.out.println("Added lemon."); }Added soda.Added ice.Added straw.Added water.Added soda.Added ice.Added straw.Added water.Added ice.Added straw.Added water.Added soda.Added ice.Added straw.Added lemon.
Solution
The output of the program will be:
Added soda. Added ice. Added straw.
Similar Questions
Which of these is the output of the following program?int tempFahrenheit = 36;if (tempFahrenheit < 32){ System.out.println("Must be freezing!");} else if (tempFahrenheit > 80) { System.out.println("Getting hot!");} else { System.out.println("Seems like a nice day!");}a.)Getting hot!b.)Must be freezing!Getting hot!Seems like a nice day!c.)Must be freezing!d.)Seems like a nice day!
What will be the output of the following Java program?class java { public static void main(String args[]) { int var1 = 3; int var2 = 8; if ((var2 = 2) == var1) System.out.print(var2); else System.out.print(++var2); } }Options3421
What will be the output of the following Java program?class mainclass { public static void main(String args[]) { boolean ct1 = true; boolean ct2 = false; if (ct1) System.out.println(ct1); else System.out.println(ct2); } }Options10truefalse
What would be the output of the following code snippet if variable p=10?if(p<=0){ if(p==0) { System.out.println("4 "); } else { System.out.println("5 "); }}System.out.println("6 ");Options2 31 21 36
rect answerWhat will be the output of the following Java program?class conditional_statements { public static void main(String args[]) { final int u=10,v=20; while(u<v) { System.out.println("Good"); } System.out.println("Morning"); } }
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.