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)

C2 – True- False Questions and Answers 2025

Rating
-
Sold
-
Pages
3
Grade
A+
Uploaded on
23-06-2025
Written in
2024/2025

Exam of 3 pages for the course CMSC 132 at CMSC 132 (C2 – True- False)

Institution
CMSC 132
Course
CMSC 132

Content preview

C2 – True- False

1) If x is a string, then x = new String("OH"); and x = "OH"; will accomplish the same
thing. T/F ? - answerTrue. Explanation: In Java, to instantiate (assign a value to) an
object, you must use new and the class's constructor. However, since Strings are so
common in Java, they can be instantiated in a way similar to assigning primitive types
their values. So, both of the above assignment statements will accomplish the same
task.

2) If x is the String "Hi There", then x.toUpperCase().toLowerCase(); will return the
original version of x. T/F ? - answerFalse. Explanation: x.toUpperCase() returns x as all
capital letters, while x.toLowerCase() will return x as all lower case letters. So, this code
will first convert x to all upper case letters and then convert the new version to all lower
case characters.

3) If String name = "George W. Bush"; then the instruction name.length(); will return 14.
T/F ? - answerTrue. Explanation: There are 14 characters in the quote marks including
two blanks and a period,

4) If String a = "ABCD" and String b = "abcd" then a.equals(b); returns false but
a.equalsIgnoreCase(b); returns true. T/F ? - answerTrue. Explanation: Since "ABCD" is
not the same as "abcd", the equals method returns false, but by ignoring case in
equalsIgnoreCase, the two are considered true.

5) Unlike the String class where you must pass a message to an object (instance) of the
class, as in x.length( ), in order to use the Math class, you pass messages directly to the
class name, as in Math.abs( ). T/F ? - answerTrue. Explanation: The Math class uses
methods known as static methods (or class methods) which are invoked by passing a
message directly to the class name itself rather than to an object of the class.

6) A double is wider than an int. T/F ? - answerTrue. Explanation: Wider types are larger
in size or can store a greater range of values. The double is 64 bits and because of the
way it is stored, can store a significantly larger range of values than the int.

7) A variable of type boolean will store either a 0 or a 1. T/F ? - answerFalse.
Explanation: A boolean variable can store only one of two values, but these values are
the reserved words true and false. In C and C++, booleans are implemented as int
variables that store only a 0 or a 1, but in Java, the authors of the language opted to use
the boolean literals true and false as this is considered to be semantically more
understandable.

Written for

Institution
CMSC 132
Course
CMSC 132

Document information

Uploaded on
June 23, 2025
Number of pages
3
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

$16.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.
Dreamer252 NBursing
Follow You need to be logged in order to follow users or courses
Sold
494
Member since
3 year
Number of followers
297
Documents
21489
Last sold
1 day ago

4.0

120 reviews

5
64
4
23
3
18
2
2
1
13

Recently viewed by you

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