Sunday, 5 November 2017

java problems and their solution



Problem 10:
What is the output of  the following question if enter 4
System.out.println("Enter the day number");
  int day=input.nextInt();
   switch (day) {
case 1:
case 2:
case 3:
case 4:
case 5: System.out.println("Weekday"); break;
case 0:
case 6: System.out.println("Weekend");
Output:
Weekday
Problem 11:
What is the output of  the following question
int x = 1, a = 3;
if (a == 1)
x += 5;
else if (a == 2)
x += 10;
else if (a == 3)
x += 16;
else if (a == 4)
x += 34;
Output:
17
Problem 12:
What is the output of  the following question
int x,y;
 x = 3; y = 3;
switch (x + 3) {
case 6: y = 1;
default: y += 1;
} System.out.print(y);
 }
}

Output:
2
Problem 13:
What is the output of  the following question
System.out.println(3*3/4*8+3);
Output:
19
Problem 14:
What is the output of  the following question
System.out.println(3*3/4*8+99/1.0+3);
Output:
118

No comments:

Post a Comment