Show List
Quiz - Java operators, control structures and arrays - 1
Select the right answer for below questions:
What is the value of x after the following code is executed: int x = 10; x += 5;
10
15
20
25
15
What is the output of the following code: int num = 5; System.out.println(num > 2 ? "Greater" : "Lesser");
5
Lesser
Greater
None of the above
Greater
What is the difference between the & and && operators in Java?
Both & and && are logical operators
& is a logical operator, && is a bitwise operator
Both & and && are bitwise operators
& is a bitwise operator, && is a logical operator
& is a bitwise operator, && is a logical operator
What is the output of the following code: int num1 = 10, num2 = 20; if (num1 < num2) { System.out.println("num1 is lesser"); }
num1 is lesser
num2 is lesser
None of the above
10
num1 is lesser
What is the output of the following code: int x = 10, y = 20; System.out.println(x + y);
10
20
25
30
30
What is the output of the following code: int num = 5; while (num < 10) { System.out.println(num); num++; }
5
6
7
All of the above
All of the above
What is the value of the following expression: 4 % 3
7
2
3
1
1
What is the output of the following code: int[] numbers = {1, 2, 3, 4, 5}; for (int num : numbers) { System.out.println(num); }
1
2
3
All of the above
All of the above
What is the size of the following array: int[] numbers = new int[5];
0
1
5
10
5
What is the output of the following code: int num = 5; do { System.out.println(num); num++; } while (num < 10);
5
6
7
All of the above
All of the above
Submit
Retry
{"qz1-690621":"15","qz1-690622":"Greater","qz1-690623":"& is a bitwise operator, && is a logical operator","qz1-690624":"num1 is lesser","qz1-690625":"30","qz1-690626":"All of the above","qz1-690627":"1","qz1-690628":"All of the above","qz1-690629":"5","qz1-690630":"All of the above"}
Leave a Comment