100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Exam (elaborations)

Java Final Exam Multiple Choice Questions With Solutions

Rating
-
Sold
-
Pages
38
Grade
A+
Uploaded on
14-07-2023
Written in
2022/2023

Java Final Exam Multiple Choice Questions With Solutions 1) The increment operator is: A) ++ B) -- C) *= D) -= - ANS Answer: A 2) What will be the values of x and y as a result of the following code? int x = 25, y = 8; x += y++; A) x = 25, y = 8 B) x = 33, y = 8 C) x = 33, y = 9 D) x = 34, y = 9 - ANS Answer: C 3) What will be the value of x after the following code is executed? int x, y = 4, z = 6; x = (y++) * (++z); A) 24 B) 28 C) 30 D) 35 - ANS Answer: B 4) This is a control structure that causes a statement or group of statements to repeat. A) Block B) Loop C) Prefix mode D) Body - ANS Answer: B 5) If a loop does not contain within itself a way to terminate, it is called a(n): A) while loop B) do-while loop C) for loop D) infinite loop - ANS Answer: D 6) Each repetition of a loop is known as what? A) An iteration B) A cycle C) An execution D) A Lap - ANS Answer: A 7) This variable controls the number of times that the loop iterates. A) Counter variable B) Loop control variable C) Running total D) Decrement variable - ANS Answer: B 8) This type of loop will always be executed at least once. A) pre-test loop B) post-test loop C) sentinel loop D) for loop - ANS Answer: B 9) If you are using a block of statements, don't forget to enclose all of the statements in a set of: A) Braces B) Double quotes C) Semicolons D) Parentheses - ANS Answer: A 10) What will be the value of x after the following code is executed? int x = 10; while (x < 100) { x += 10; } A) 90 B) 100 C) 110 D) This is an infinite loop. - ANS Answer: B 11) What will be the value of x after the following code is executed? int x = 10, y = 20; while (y < 100) {

Show more Read less
Institution
JAVA
Course
JAVA











Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Institution
JAVA
Course
JAVA

Document information

Uploaded on
July 14, 2023
Number of pages
38
Written in
2022/2023
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

Content preview

Java
Final
Exam
Multiple
Choice
1)
The
increment
operator
is:
A)
++
B)
--
C)
*=
D)
-=
-
ANS
Answer:
A
2)
What
will
be
the
values
of
x
and
y
as
a
result
of
the
following
code?
int
x
=
25,
y
=
8;
x
+=
y++;
A)
x
=
25,
y
=
8
B)
x
=
33,
y
=
8
C)
x
=
33,
y
=
9
D)
x
=
34,
y
=
9
-
ANS
Answer:
C
3)
What
will
be
the
value
of
x
after
the
following
code
is
executed?
int
x,
y
=
4,
z
=
6;
x
=
(y++)
*
(++z);
A)
24
B)
28
C)
30
D)
35
-
ANS
Answer:
B
4)
This
is
a
control
structure
that
causes
a
statement
or
group
of
statements
to
repeat.
A)
Block
B)
Loop
C)
Prefix
mode
D)
Body
-
ANS
Answer:
B
5)
If
a
loop
does
not
contain
within
itself
a
way
to
terminate,
it
is
called
a(n):
A)
while
loop
B)
do-while
loop
C)
for
loop
D)
infinite
loop
-
ANS
Answer:
D
6)
Each
repetition
of
a
loop
is
known
as
what?
A)
An
iteration B)
A
cycle
C)
An
execution
D)
A
Lap
-
ANS
Answer:
A
7)
This
variable
controls
the
number
of
times
that
the
loop
iterates.
A)
Counter
variable
B)
Loop
control
variable
C)
Running
total
D)
Decrement
variable
-
ANS
Answer:
B
8)
This
type
of
loop
will
always
be
executed
at
least
once.
A)
pre-test
loop
B)
post-test
loop
C)
sentinel
loop
D)
for
loop
-
ANS
Answer:
B
9)
If
you
are
using
a
block
of
statements,
don't
forget
to
enclose
all
of
the
statements
in
a
set
of:
A)
Braces
B)
Double
quotes
C)
Semicolons
D)
Parentheses
-
ANS
Answer:
A
10)
What
will
be
the
value
of
x
after
the
following
code
is
executed?
int
x
=
10;
while
(x
<
100)
{
x
+=
10;
}
A)
90
B)
100
C)
110
D)
This
is
an
infinite
loop.
-
ANS
Answer:
B
11)
What
will
be
the
value
of
x
after
the
following
code
is
executed?
int
x
=
10,
y
=
20;
while
(y
<
100)
{
x
+=
y;
} A)
90
B)
110
C)
210
D)
This
is
an
infinite
loop.
-
ANS
Answer:
D
12)
________
is
the
process
of
inspecting
data
given
to
the
program
by
the
user
and
determining
if
it
is
valid.
A)
Data
parsing
B)
Input
validation
C)
User
authentication
D)
Defensive
coding
-
ANS
Answer:
B
13)
This
type
of
loop
allows
the
user
to
decide
the
number
of
iterations.
A)
Counter-controlled
loop
B)
Dynamically
executed
loop
C)
User
controlled
loop
D)
Infinite
loop
-
ANS
Answer:
C
14)
In
the
following
code,
what
values
could
be
read
into
number
to
terminate
the
while
loop?
Scanner
keyboard
=
new
Scanner(System.in);
System.out.print("Enter
a
number
");
int
number
=
keyboard.nextInt();
while
(number
<
100
&&
number
>
500)
{
System.out.print("Enter
another
number
");
number
=
keyboard.nextInt();
}
A)
Numbers
less
than
100
or
greater
than
500
B)
Numbers
in
the
range
100
-
499
C)
Numbers
in
the
range
100
-
500
D)
The
boolean
condition
can
never
be
true.
-
ANS
Answer:
D
15)
What
will
be
the
value
of
x
after
the
following
code
is
executed?
int
x
=
10;
do
{
x
*=
20;
} while
(x
>
5);
A)
10
B)
200
C)
This
is
an
infinite
loop.
D)
The
loop
will
not
be
executed,
the
initial
value
of
x
>
5.
-
ANS
Answer:
C
16)
How
many
times
will
the
following
do-while
loop
be
executed?
int
x
=
11;
do
{
x
+=
20;
}
while
(x
>
100);
A)
0
B)
1
C)
4
D)
5
-
ANS
Answer:
B
17)
A
loop
that
repeats
a
specific
number
of
times
is
known
as
a(n):
A)
sentinel
loop
B)
conditional
loop
C)
counter-controlled
loop
D)
infinite
loop
-
ANS
Answer:
C
18)
How
many
times
will
the
following
for
loop
be
executed?
for
(int
count
=
10;
count
<=
21;
count++)
System.out.println("Java
is
great!!!");
A)
1
B)
10
C)
12
D)
0
-
ANS
Answer:
C
19)
What
will
be
the
value
of
x
after
the
following
code
is
executed?
int
x
=
10;
for
(int
y
=
5;
y
<
20;
y
+=5)
x
+=
y;
A)
40
B)
25
C)
30
D)
Invalid
for
statement
-
ANS
Answer:
A

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
Studyclock Ashford University
View profile
Follow You need to be logged in order to follow users or courses
Sold
842
Member since
3 year
Number of followers
491
Documents
8831
Last sold
1 day ago

4.2

219 reviews

5
131
4
33
3
33
2
10
1
12

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions