Question: (a)How many times does the code snippet given below display Hello? int x = 1; while (x != 15) { System.out.println (Hello); x++; } (b)What

(a)How many times does the code snippet given below display "Hello"?

int x = 1;

while (x != 15)

{

System.out.println ("Hello");

x++;

}

(b)What is the output of the following code fragment?

int i = 1;

int sum = 0;

while (i <= 5)

{

sum = sum + i;

i++;

}

System.out.println("The value of sum is " + sum);

Quie 2

What is the output of the following snipped code?

public class Test {

public static void main(String args[]) {

int x = 45;

int y = 10;

if( x == 30 ) {

if( y == 10 ) {

System.out.print("X = 30 and Y = 10");

else

System.out.print("X = 45 and Y = 10");

}

}

System.out.print("Nested If");

If the user enter 2000, what is the output of the code segment shown below?

public class Leapyear{

public static void main(String[] args) {

int year;

Scanner console = new Scanner(System.in);

System.out.print("Enter a year : ");

year = console.nextInt();

if (year % 4 == 0) {

if (year % 100 == 0) {

if (year % 400 == 0) {

System.out.println("A leap year");

}

else {

System.out.println("Not a leap year");

}

}

else {

System.out.println("A leap year");

}

}

else {

System.out.println("Not a leap year");

} } }

qstion Three

What is the output of:

for (int i=1; i <= 5; i++)

{

for (int j=1; j <= 5; j++)

System.out.print (i*j + " ");

System.out.println();

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!