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

1. What is the output of the following program? public class One public static v

ID: 3832249 • Letter: 1

Question

1. What is the output of the following program? public class One public static void main (String0 args) if (number system out-printin TERROR: Number is less than 1."); else for lint count 1 count number: count+ 2) system out printm (Alamn; Your answer: 2. What is the output of the following program? public class TwoH public static void main (Stringt args) int num 1: for (int power 1; power 10, power num 2: System out println (num): Your answer: 3. hat value is assigned toxin the program segment below? public class Three public static void main (StringO args) double x 25.0; if (x (x- 10.0) x -10.0. else system out.printinrx b. 13 15 d.. 25

Explanation / Answer

1.

The increment is I=I+2

So output will be 3 alarms

Alarm!

Alarm!

Alarm!

2.it prints the power of 2till 10 iterations

2

4

8

16

32

64

128

256

512

1024

3.

Here x is decremented to 10values so 25-10=15. And its not equal to 25.true so if block is executed .

X = 15.0

4.

This function increments from 1 till 9 since 10<10 is false.and prints the number and its square..power(a,2).with 2 tab spaces

Number Number manupilated
----------------------------
1           1.0
3            9.0
5              25.0
7               49.0
9              81.0

5.

It checks tthe if statement as 1st and 2nd is same if is true so and then second if statement as 1 and 3 is not equal the else block gets executed

o/p is : Mark and Mark are......................................?

Mark and MAry are NOT......................................?

6.Thius will execute infinitly.because the condition is max<=4 which is true allways as it is not decremented,It indefinitly prints squares of number from 1 and return runtime error once memory is exhausted.

i 1
i 9
i 25
i 49
i 81
so on