Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Exam (elaborations)

CS 170 Java Final || Questions and 100% Accurate Answers.

Rating
-
Sold
-
Pages
10
Grade
A+
Uploaded on
25-03-2025
Written in
2024/2025

A loop that searches for a particular value in input is called a(n) : correct answers sentinel loop final int LASTVAL = -99; Scanner cin = new Scanner(S); int entry = Int(); while (entry != LASTVAL) { int triple = entry * 3; Sln(triple); entry = Int(); } The above code is an example of a(n) ____ while loop. correct answers sentinel-controlled Which executes first in a do...while loop? correct answers statement What is the output of the following Java code? int num = 0; while (num 5) { S(num + " "); num = num + 1; } Sln(); correct answers 0 1 2 3 4 Suppose sum and num are int variables, and the input is What is the output of the following code? Scanner cin = new Scanner(S); sum = 0; num = Int(); while (num != -1) { sum = sum + num; num = Int(); } Sln(sum); correct answers 110 int x = 5; int y = 30; do x = x * 2; while (x y);

Show more Read less
Institution
CS 170 Java
Course
CS 170 Java

Content preview

CS 170 Java Final || Questions and 100% Accurate Answers.
A loop that searches for a particular value in input is called a(n) : correct answers sentinel loop

final int LASTVAL = -99;
Scanner cin = new Scanner(System.in);
int entry = cin.nextInt();

while (entry != LASTVAL)
{
int triple = entry * 3;
System.out.println(triple);
entry = cin.nextInt();
}
The above code is an example of a(n) ____ while loop. correct answers sentinel-controlled

Which executes first in a do...while loop? correct answers statement

What is the output of the following Java code?
int num = 0;
while (num < 5)
{
System.out.print(num + " ");
num = num + 1;
}
System.out.println(); correct answers 0 1 2 3 4

Suppose sum and num are int variables, and the input is
18 25 61 6 -1
What is the output of the following code?
Scanner cin = new Scanner(System.in);
sum = 0;
num = cin.nextInt();
while (num != -1)
{
sum = sum + num;
num = cin.nextInt();
}
System.out.println(sum); correct answers 110

int x = 5;
int y = 30;

do
x = x * 2;
while (x < y);

, If y = 0,
How many times would the loop above execute? correct answers 1

What is the output of the following Java code?
int x = 1;

do
{
System.out.print(x + " ");
x--;
}
while (x > 0);

System.out.println(); correct answers 1

Which of the following is not a function of the break statement? correct answers To ignore
certain values for variables and continue with the next iteration of a loop

Suppose that the input is

5 3 4 -6 8
What is the output of following Java code fragment?
Scanner cin = new Scanner(System.in);
int sum = 0;
int num;
for (int j = 1; j <= 5; j++)
{
num = cin.nextInt();
if (num < 0)
continue;

sum = sum + num;
}

System.out.println(sum); correct answers 20

The hasNext method returns ____ when trying to read past the end of the input file. correct
answers false

Which of the following about Java arrays is true?
(i) All components must be of the same type.
(ii) The array index and array element must be of the same type. correct answers Only (i)

You can create an array of three doubles by writing : correct answers double ar[] = { 1.1, 2.2, 3.3
};

Written for

Institution
CS 170 Java
Course
CS 170 Java

Document information

Uploaded on
March 25, 2025
Number of pages
10
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

$11.99
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF


Also available in package deal

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.
SirAnton NURSING, ECONOMICS, MATHEMATICS, BIOLOGY, AND HISTORY MATERIALS BEST TUTORING, HOMEWORK HELP, EXAMS, TESTS, AND STUDY GUIDE MATERIALS WITH GUARANTEED A+ I am a dedicated medical practitioner with diverse knowledge in matters
Follow You need to be logged in order to follow users or courses
Sold
786
Member since
3 year
Number of followers
438
Documents
39233
Last sold
1 week ago
Reign Supreme Scholarly || Enlightened.

Get your revised study materials available here and elevate your educational outcomes. I have numerous verified learning materials (Research, Exams Questions and answers, Assignments, notes etc) for different courses guaranteed to boost your academic results. I am dedicated to offering you the best and unique learning content. You are encouraged to inquire further assistance from this end whenever need be. Kindly remember to leave your review, understanding your satisfaction is essential . We highly appreciate clients who always come back for more of the study content we offer, you are extremely valued. All the best.

Read more Read less
3.7

116 reviews

5
49
4
20
3
23
2
8
1
16

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

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions