Runthefollowingcode


Question 1

1. Run the following code:

Int I =2147389549;
Boolean flag = true;
While(flag){
System.out.println(i);
i=i+1;
}

2. Explain the loop;

3. Explain the output aYer you let it run 20 seconds, 5 minutes, 10 minutes.

Question 2

1. Run the following code:

Int I =2147389549;
Boolean flag = true;
While(flag){
System.out.println(i);
If(i==0) i=i+1;
Else if (i<0) flag = false;
Else i++;}

2. Explain the output;

3. What happens if you initialize the value with 2147389548?

4. Fix the loop to stop when i overflows.

5. Run it the modification

Question 3

1. Run the following code:

String ruler1 = "1";
String ruler2 = ruler1 + "2" + ruler1;
String ruler3 = ruler2 + "3" + ruler2;
String ruler4 = ruler3 + "4" + ruler3;
String ruler5 = ruler4 + "5" + ruler4;

System.out.println(ruler1);
System.out.println(ruler2);
System.out.println(ruler3);
System.out.println(ruler4);
System.out.println(ruler5);

2. Set a while loop to do produce the same output.

3. Run it

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: Runthefollowingcode
Reference No:- TGS01038782

Expected delivery within 24 Hours