Enter the result
What does this code print?
int n = 0;
System.out.print(++n);
System.out.print(n++);
System.out.print(n++);
Keep in mind that all numbers are printed on the same line.
Java Basic
Quiz
•
Computers
•
University
•
Hard
Nhi Nguyễn
Used 3+ times
FREE Resource
42 questions
Show all answers
1.
FILL IN THE BLANK QUESTION
1 min • 1 pt
Enter the result
What does this code print?
int n = 0;
System.out.print(++n);
System.out.print(n++);
System.out.print(n++);
Keep in mind that all numbers are printed on the same line.
2.
FILL IN THE BLANK QUESTION
1 min • 1 pt
What does the following code print?
int n = 10;
n--;
System.out.println(n++);
3.
FILL IN THE BLANK QUESTION
1 min • 1 pt
Enter the value of result:
int a = 4;
int b = a++;
int c = --a + b++;
int result = ++a - (c++ - b) + c;
Answer explanation
1. a = 4
2. b = a++ that means first we assign a's value to b then increment a, so b = 4 and a = 5
3. c= --a + b++ = 4 + 4 = 8, so final value of a = 4 and b = 5 (As we assign first then increment)
4. res = ++a - (c++ - b) + c = 5 - (8-5) + 9 = 11 (here also first you assign c's value in bracket then increment in the end)
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the result ?
Given the following code:
int a = -1;
System.out.println(1 - a++);
1
0
-1
2
3
Answer explanation
There are 3 actions here:
- The first one will be (1 - a). //This will result in 1 - (-1) = 2.
- The second will be (a++). //This will increase the value of a by 1, which is (-1)++ will equal to 0.
- The third will be the sum of the first and the second (2 + 0) = 2.
5.
MULTIPLE SELECT QUESTION
45 sec • 1 pt
Choose all syntatically correct ways to write the for-loop. Remember the difference between syntax rules and coding conventions.
You are unlikely to use some of these methods, but it is important to understand exactly how the for-loop works.
for (int i = 0; i < 10; i++) { /* body */ }
int i = 0; for (; i < 10; ++i) { /* body */ }
for (int k = 10; k > 1; ) { k--; /* some statements */ }
for (;;) { /* body */ }
6.
MULTIPLE SELECT QUESTION
45 sec • 1 pt
The control structure is also known as a
repetitive conditional statement
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
The number of loop body executions:
How many times will the loop body be executed?
0
1
2
3
4
Answer explanation
when counter == 3, if conditional is true and there is no break in it just reassigning the boolean shouldBeStopped to true, then counter++ (it makes counter 4) and when while loop condition is evaluated again
42 questions
App inventor
Quiz
•
7th Grade - University
40 questions
Elements of a C# program
Quiz
•
University
40 questions
Latihan 1 PBO XI RPL 2
Quiz
•
10th Grade - University
45 questions
TECHNICAL QUIZ
Quiz
•
University
40 questions
Java Quiz
Quiz
•
University
40 questions
Arrays and ArryList
Quiz
•
University
40 questions
Data Structures and Algorithms Quiz
Quiz
•
University
45 questions
Programming
Quiz
•
12th Grade - University
15 questions
Character Analysis
Quiz
•
4th Grade
17 questions
Chapter 12 - Doing the Right Thing
Quiz
•
9th - 12th Grade
10 questions
American Flag
Quiz
•
1st - 2nd Grade
20 questions
Reading Comprehension
Quiz
•
5th Grade
30 questions
Linear Inequalities
Quiz
•
9th - 12th Grade
20 questions
Types of Credit
Quiz
•
9th - 12th Grade
18 questions
Full S.T.E.A.M. Ahead Summer Academy Pre-Test 24-25
Quiz
•
5th Grade
14 questions
Misplaced and Dangling Modifiers
Quiz
•
6th - 8th Grade