Java Basic

Java Basic

University

42 Qs

quiz-placeholder

Similar activities

Arquitetura de Computadores P1

Arquitetura de Computadores P1

University

38 Qs

MS office 2016

MS office 2016

1st Grade - Professional Development

40 Qs

Computer Network

Computer Network

12th Grade - University

40 Qs

TỔNG HỢP CHƯƠNG 2 - TIN 12

TỔNG HỢP CHƯƠNG 2 - TIN 12

12th Grade - University

40 Qs

Data Structures & Algorithm

Data Structures & Algorithm

University

40 Qs

E-Commerce UNJ 2020 By @pakdosenshandy

E-Commerce UNJ 2020 By @pakdosenshandy

University

40 Qs

Quiztitude

Quiztitude

University

40 Qs

Révisions TLM3A - CPMB - Colombier

Révisions TLM3A - CPMB - Colombier

10th Grade - Professional Development

42 Qs

Java Basic

Java Basic

Assessment

Quiz

Computers

University

Practice Problem

Hard

Created by

Nhi Nguyễn

Used 3+ times

FREE Resource

AI

Enhance your content in a minute

Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...

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

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?

Discover more resources for Computers