Java Final Exam Multiple Choice Questions With Solutions
19 views 0 purchase
Course
JAVA
Institution
JAVA
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) ...
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
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller Studyclock. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $12.99. You're not tied to anything after your purchase.