Java Basic

Java Basic

University

42 Qs

quiz-placeholder

Similar activities

Loop Control Statement in C

Loop Control Statement in C

University

41 Qs

A4ALGU CLUB EVENT QUIZ

A4ALGU CLUB EVENT QUIZ

University

40 Qs

C Programming

C Programming

University

40 Qs

Coding Skill Test -I

Coding Skill Test -I

University

40 Qs

Round 1 Code2duo

Round 1 Code2duo

University

44 Qs

C++ Quiz

C++ Quiz

University

40 Qs

Quiz Penilaian AP2A

Quiz Penilaian AP2A

University

40 Qs

Java Quiz

Java Quiz

University

40 Qs

Java Basic

Java Basic

Assessment

Quiz

Computers

University

Hard

Created by

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)

  1. 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

pre-test loop
post-test loop
exit-condition loop

repetitive conditional statement

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Media Image

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

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?