Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using Java, answer the following What will be the O/P produced by the following

ID: 3809838 • Letter: U

Question

Using Java, answer the following

What will be the O/P produced by the following code? int a = 2; int b = 7; Boolean go Ahead = true; Boolean stop = ( a >= 3 ); if (goAhead ) { a = a+l; System.out.print (Value a= + a); } else if ( stop ) System.out.print (Value a= + a); System.out.print ("At end value of a = " + a + value of b = + b ); What will be the O/P produced by the following code, if the calculated bMI value are (1) 18.5, (2) 23, (3) 29, (4) 30 ANS the O/P in the corresponding Line(#) int w, h; double bMI; String uWM = You are underweight; //underweight message String uWM2 = you should eat enough food; String nWM = You are in normal weight range; //normal weight message String nWM2 = you may keep your life style; String oWM = You are overweight; //overweight message String oWM2 = you should cut food amount & do exercise; String tWM = You are in obesity range (too fat); //obesity message String tWM2 = you need eat less & do hard exercise; //ifthe calculated bMI = (1) 18.5, (2)23, (3)29,(4)30 if(bMI

Explanation / Answer

20. Value a=3At end Value of a=3 Value of b=7

Explaination:since goahead is true, else statement (whose block contains if condition with single system.out.print) won't be executed

21 Line(1)You are underweight, you should eat enough food
Line(2)You are in normal weight range, you may keep your life style

Line(3)You are overweight, you should cut food amount & do exercise
   Line(4)You are in obesity range (too fat), you need eat less & do hard exercise

Explaination: its an example of if else if decision flow, which will execute its system.out.print statement whenever condition get satisfied.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote