
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
Enter the result:
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
Such different for loops
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
Create a free account and access millions of resources
Similar Resources on Wayground
40 questions
Array of Structures 2

Quiz
•
University
44 questions
UTS IF X - GENAP

Quiz
•
12th Grade - University
40 questions
Trivia(Explore in depth)

Quiz
•
University
40 questions
Latihan 1 Pemrograman Dasar

Quiz
•
University
38 questions
Тест 2 C#

Quiz
•
University
40 questions
Midterm Examination

Quiz
•
University
40 questions
Playing Code!

Quiz
•
University
38 questions
Digital Systems Quiz

Quiz
•
University
Popular Resources on Wayground
10 questions
Video Games

Quiz
•
6th - 12th Grade
10 questions
Lab Safety Procedures and Guidelines

Interactive video
•
6th - 10th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
10 questions
UPDATED FOREST Kindness 9-22

Lesson
•
9th - 12th Grade
22 questions
Adding Integers

Quiz
•
6th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
20 questions
US Constitution Quiz

Quiz
•
11th Grade
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade
Discover more resources for Computers
10 questions
Would you rather...

Quiz
•
KG - University
20 questions
Definite and Indefinite Articles in Spanish (Avancemos)

Quiz
•
8th Grade - University
7 questions
Force and Motion

Interactive video
•
4th Grade - University
10 questions
The Constitution, the Articles, and Federalism Crash Course US History

Interactive video
•
11th Grade - University
7 questions
Figurative Language: Idioms, Similes, and Metaphors

Interactive video
•
4th Grade - University
20 questions
Levels of Measurements

Quiz
•
11th Grade - University
16 questions
Water Modeling Activity

Lesson
•
11th Grade - University
10 questions
ACT English prep

Quiz
•
9th Grade - University