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
Document preview thumbnail
Preview 3 out of 17 pages
Exam (elaborations)

CS 1400 FINAL REVIEW QUESTIONS WITH VERIFIED ANSWERS

Document preview thumbnail
Preview 3 out of 17 pages

CS 1400 FINAL REVIEW QUESTIONS WITH VERIFIED ANSWERS

Content preview

CS 1400 FINAL REVIEW QUESTIONS WITH VERIFIED
ANSWERS


True or False, the best way to make a single line comment is by using the /** **/
comment style. - Answers - False, it is //

Which of the following commands will generate the output below?
Hello World! - Answers - System.out.print("Hello World!");

Which of the following best describes how troubleshooting and correcting compiling
errors should be approached? - Answers - Fix one error at a time and work your way to
fixing all compiling errors.

True or False, Computer programming jobs are becoming few and far between because
machines have taken over the task of creating and maintaining current applications. -
Answers - False.

Part of being a good programmer includes the ability to effectively troubleshoot and
solve problems. - Answers - True.

What are two valid numerical variable types? - Answers - double and int

Which of the following is a valid way in Java of assigning the variable x with the value of
x + 3? - Answers - x = x + 3;

Consider the following code:

import java.util.Scanner;
public class GetUsersName {
public static void main (String[] args) {
Scanner scnr = new Scanner(System.in);
??? inputUserName;
System.out.print("Please enter your name: ");
inputUserName = scnr.nextLine();
System.out.println("Hello " + inputUserName);
}
}

Which of the following variable types should be used in this scenario where the ???s
are located? - Answers - String

Which is a shorthand way of subtracting 5 from the value already assigned to variable
x? - Answers - x -= 5;

,Which of the following is a valid value that can be assigned to a Boolean variable? -
Answers - true

Consider the following code:

int userAge = 60;
double discountPercentage = 0.0;

if (userAge > 60)
{
discountPercentage = 0.15;
}
else if (userAge < 60)
{
discountPercentage = 0.10;

}
discountPercentage *= 100;
System.out.println("The discount percentage is " + discountPercentage + "%");

What will the discount percentage value be that is displayed to the user? - Answers -
0.0%

Would you say the code in the previous question is operating correctly? Are there any
syntax or logic errors, or is the code complete and correct? - Answers - The code has
one or more logic errors.
It doesn't make sense.... think about it... if you are under 60 you get 10% off, if you are
above 60 you get 15%, and if you are 60 you get no discount. that's weird right?

True or false.
Multiple if statements can be nested inside each other. - Answers - True.

True or false.
If statements must contain either an else or an else if, otherwise a compiling error will
occur. - Answers - False.

Write an if statement that checks if a person is exactly 16 years old. If the statement
evaluates to true, print a line stating "Happy Sweet 16!". You can use the variable
userAge to write the statement. You do not need to write the statements necessary to
declare the variable or capture the input (unless you want to show off). - Answers - int
userAge = 16;

if(userAge == 16) {

System.out.println("Happy Sweet 16!");

, }

True or false.
Loops can only work with positive values. No negative values can be used. - Answers -
False.

A(n) ___________ is the word used to describe each cycle or repetition through a loop.
- Answers - iteration

True or false.
Infinite loops are usually favorable because they ensure that the program will continue
running and operating as intended. - Answers - False.

What is the name of the value that can be used to immediately end or terminate a loop?
- Answers - sentinel

When the number of times a loop should run is a known number, a for loop is the better
option. - Answers - True.

Which term accurately describes placing one loop inside of another loop? - Answers -
Nesting

Write a for loop that will run 5 times and display the following output:

0
1
2
3
4 - Answers - for (int i = 0; i < 5; i++)
{
System.out.println(i);
}

Write a while loop that will run 5 times and display the following output:

5
4
3
2
1 - Answers - Scanner scnr = new Scanner(System.in);
int x = 5;

while (x >= 1)
{
System.out.println(x);

Document information

Uploaded on
July 24, 2026
Number of pages
17
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers
$14.99

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

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.
GEEKA
3.8
(361)
Sold
2138
Followers
1448
Items
58662
Last sold
10 hours ago


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