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 2 out of 7 pages
Exam (elaborations)

CPS 121 Final Review Exam Complete Questions and Answers.

Document preview thumbnail
Preview 2 out of 7 pages

CPS 121 Final Review Exam Complete Questions and Answers. Which of the following is a value that is written into the code of a program? - Answer Literal A Java program must have at least one of the following - Answer a class definition Which of the following is a named storage location in the computer's memory? - Answer a variable Which of the following is not a valid Java comment? - Answer */ Comment two/* To compile a program named First you would use which of the following commands? - Answer javac F A Java source file must be saved with the extension - Answer .java Character literals are enclosed in ________; string literals are enclosed in ________. - Answer single qu

Content preview

CPS 121 Final Review Exam Complete Questions and
Answers.
Which of the following is a value that is written into the code of a program? - Answer
Literal

A Java program must have at least one of the following - Answer a class definition

Which of the following is a named storage location in the computer's memory? -
Answer a variable

Which of the following is not a valid Java comment? - Answer */ Comment two/*

To compile a program named First you would use which of the following commands?
- Answer javac First.java

A Java source file must be saved with the extension - Answer .java

Character literals are enclosed in ________; string literals are enclosed in ________.
- Answer single quotes, double quotes

Variable are classified according to their - Answer data types

What is the result of the following expression:
17 % 3 * 2 - 12 + 15 - Answer 7

What is the result of the following expression:
10 + 5 * 3 - 20 - Answer 5

What output will be displayed as a result of executing the following code:
int x = 5, y = 20;
x += 32;
y /= 4;
System.out.println("x =" + x + ", y =" + y); - Answer x = 37, y = 5

What would be displayed as a result of executing the following code:
int x = 578;
System.out.print("There are" + x + 5 "\n" + "hens in the hen house."; - Answer There
are 5785
hens in the hen house.

Which of the following statements correctly creates a Scanner object for keyboard
input? - Answer Scanner keyboard = new Scanner(System.in);

If the following Java statements are executed, what will be displayed?

, System.out.println("The top three winners are\n");
System.out.print("Jody, the Giant\n");
System.out.print("Buffy, the Barbarian");
System.out.println("Adelle, the Alligator"); - Answer The top three winners are
Jody, the Giant
Buffy, the BarbarianAdelle, the Alligator

When the + operator is used with strings, it is known as the: - Answer string
concatenation operator

Which of the following cannot be used as identifiers in Java? - Answer key words

If x has been declared an int, which of the following statements is invalid? - Answer x
= 1,000;

To display the output on the next line, you can use the println method or use the
_________ escape sequence in the print method. - Answer \n

Every Java application must have - Answer a method named main

In an if-else statement, if the boolean expression is false then______ - Answer the
statement or block following the else is executed

The switch statement is a _______ - Answer multiple alternative decision structure

If str1 and str2 are both String objects, which of the following expressions will
correctly determine whether or not they are equal? - Answer str1.equals(str2)

A block of code is enclosed in a set of _______ - Answer braces, { }

What will be the value of x after the following statements are executed:
int x = 75;
int y = 60
if (x>y)
x = x - y; - Answer 15

What will be displayed after the following statements are executed:
int y = 10;
if (y == 10)
{
int x = 30
x += y;
System.out.println(x);
} - Answer 40

What will be the value of the pay after the following statements are executed:

Document information

Uploaded on
February 8, 2025
Number of pages
7
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers
$18.49

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.
Excellentgrader
4.0
(23)
Sold
116
Followers
92
Items
6637
Last sold
2 months 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