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

CMSC 131 EXAM 2 QUESTIONS WITH VERIFIED ANSWERS

Document preview thumbnail
Preview 3 out of 29 pages

CMSC 131 EXAM 2 QUESTIONS WITH VERIFIED ANSWERS

Content preview

CMSC 131 EXAM 2 QUESTIONS WITH VERIFIED ANSWERS




Correct 31

Incorrect 00


Your answers


1 of 31

Definition



s = c == 'y' ? "Yes" : "No";



Give this one a try later!



public class Values {
private String distance;
private double cost;
private boolean completed;


public static void main(String[] args) {
Values values = new Values();
System.out.println(values.distance);
System.out.println(values.cost);
System.out.println(values.completed);
}
}

, When we call a.doSomething(b) which value does the special value this (present
inside of the doSomething method) have?


a. It has the same value a has
b. It has the same value b has
c. It has the value null
d. None of the above.



We can call a non-static method of a class (circle all that apply):


a. Only if an object of the class has already been created.
b. From a static method of the class.
c. By using the class name (e.g., ClassName.method)
d. None of the above.




Assuming variable c is a character type variable and s is a string type variable,
rewrite the following code using a single statement and the ternary operator
so s is assigned the correct value.


if (c == 'y') {
s = "Yes";
} else {
s = "No";
}


Don't know?




2 of 31

Definition



b



Give this one a try later!

, Which of the following actually creates an object?

a. Destructor
b. Constructor
c. new operator
d. None of the above.




Circle all the areas where an object can be found.


a. Stack
b. Heap
c. Only in the first method that has been called.
d. None of the above




Would the following class compile? Yes / No


public class Misc2 {
public static void main(String[] args) {
String m;


System.out.println(m);
}
}




Which of the following actually creates an object?


a. new
b. constructor
c. private
d. None of the above.


Don't know?

Document information

Uploaded on
July 10, 2026
Number of pages
29
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers
$12.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
2137
Followers
1449
Items
58515
Last sold
2 days 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