• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 2 out of 9 pages
Exam (elaborations)

Java Chapter 2 Review Exam Questions With Complete Solutions

Document preview thumbnail
Preview 2 out of 9 pages

JAVA CHAPTER 2 REVIEW EXAM QUESTIONS WITH COMPLETE SOLUTIONS

Content preview

JAVA CHAPTER 2 REVIEW EXAM
QUESTIONS WITH COMPLETE
SOLUTIONS

What will be displayed as a result of executing the following code?
int x = 6;
String msg = "I am enjoying this class.";
String msg1 = msg.toUpperCase();
String msg2 = msg.toLowerCase();
char ltr = msg.charAt(x);
int strSize = msg.length();
System.out.println(msg);
System.out.println(msg1);
System.out.println(msg2);
System.out.println("Character at index x = " +
ltr);
System.out.println("msg has " + strSize +
"characters."); - Answer- I am enjoying this class.
I AM ENJOYING THIS CLASS.
i am enjoying this class.
Character at index x = n
msg has 25characters.

What will be displayed as a result of executing the following code?
public class test
{
public static void main(String[] args)
{
int value1 = 9;
System.out.println(value1);
int value2 = 45;
System.out.println(value2);
System.out.println(value3);
value = 16;
}
} - Answer- Nothing, there is an error

Which of the following is NOT a valid comment statement?
A) // comment 1
B) /* comment 2 */

, C) */ comment 3 /*
D) /** comment 4 */ - Answer- C) */ comment 3 /*

When saving a Java source file, save it with an extension of:
A) .javac
B) .class
C) .src
D) .java - Answer- D) .java

Every Java application program must have:
A) a class named MAIN
B) a method named main
C) comments
D) integer variables - Answer- B) a method named main

To print "Hello, world" on the monitor, use the following Java statement:
A) SystemOutPrintln("Hello, world");
B) System.out.println{"Hello, world"}
C) System.out.println("Hello, world");
D) Print "Hello, world"; - Answer- c) System.out.println("Hello, world");

To display the output on the next line, you can use the println method or use this escape
sequence
in the print method.
A) \n
B) \r
C) \t
D) \b - Answer- A) \n

This is a named storage location in the computer's memory.
A) Literal
B) Constant
C) Variable
D) Operator - Answer- C) variable

What would be displayed as a result of 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."

Variables are classified according to their:
A) value
B) data type
C) names

Document information

Uploaded on
September 12, 2025
Number of pages
9
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers
$16.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.
wisdompoint
3.7
(20)
Sold
120
Followers
66
Items
5730
Last sold
4 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