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 14 pages
Exam (elaborations)

Java Chapter 2 Test Questions and Answers| Latest Update 100% Solved

Document preview thumbnail
Preview 2 out of 14 pages

Java Chapter 2 Test Questions and Answers| Latest Update 100% Solved

Content preview

Java Chapter 2 Test Questions and Answers|
Latest Update 100% Solved
Which of the following does not describe a valid comment in Java?
A) Single line comments, two forward slashes - //
B) Multi-line comments, start with /* and end with */
C) Multi-line comments, start with */ and end with /*

D) Documentation comments, any comments starting with /** and ending with */ ✔️✔️C) multi-
line comments, start with */ and end with /*


Which of the following statements correctly creates a Scanner object for keyboard input?
A) Scanner kbd = new Scanner(System.keyboard);
B) Scanner keyboard(System.in);
C) Scanner keyboard = new Scanner(System.in);

D) Keyboard scanner = new Keyboard(System.in); ✔️✔️C) Scanner keyboard= new
Scanner(System.in);


Which Scanner class method reads an int?
A) readInt()
B) nextInt()
C) getInt()

D) read_int() ✔️✔️B) nextInt()


Which Scanner class method reads a String?
A) readString()
B) nextString()
C) getString()

, D) nextLine() ✔️✔️D) nextLine()


Which one of the following methods would you use to convert a string to a double?
A) Byte.ParseByte
B) Long.ParseLong
C) Integer.ParseInt

D) Double.ParseDouble ✔️✔️D) Double.ParseDouble



T/F:A Java program will not compile unless it contains the correct line numbers. ✔️✔️FALSE



T/F: All Java statements end with semicolons. ✔️✔️FALSE



T/F: Java is a case-insensitive language. ✔️✔️FALSE


T/F: Although the dollar sign is a legal identifier character, you should not use it because it is
normally used

for special purposes. ✔️✔️TRUE


T/F: Assuming that pay has been declared a double, the following statement is valid.

pay = 2,583.44; ✔️✔️FALSE


T/F: Named constants are initialized with a value, that value cannot be changed during the
execution of the

program. ✔️✔️TRUE



T/F: A variable's scope is the part of the program that has access to the variable. ✔️✔️TRUE

Document information

Uploaded on
March 21, 2025
Number of pages
14
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers
$9.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.
KateJones
4.8
(12)
Sold
31
Followers
0
Items
5707
Last sold
1 week 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