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

CS2 EXAM 1 QUESTIONS AND ANSWERS WITH COMPLETE SOLUTIONS 100% CORRECT!!!

Document preview thumbnail
Preview 3 out of 27 pages

CS2 EXAM 1 QUESTIONS AND ANSWERS WITH COMPLETE SOLUTIONS 100% CORRECT!!!

Content preview

CS2 EXAM 1 QUESTIONS AND
ANSWERS WITH COMPLETE
SOLUTIONS 100% CORRECT!!!
Consider the UML class diagram shown in the accompanying figure. Which of the
following is the name of the class?


clockType
-hr: int
-min: int
-sec-: int


+setTime(int, int, int): void
+getTime(int&, int&, int&) const : void
+printTime() const: void
+incrementSeconds(): int
+incrementMinutes(): int
+incrementHours(): int
+equalTime(const clockType&) const: bool -ANSWER ✔✔clockType


Given the declaration




class myClass
{
public:

,void print(); //Output the value of x;
MyClass();


private:
int x;
};


myClass myObject;


The following statement is legal.




myObject.x = 10; -ANSWER ✔✔False


The public members of a class must be declared before the private members. -
ANSWER ✔✔False


If a function of a class is static, it is declared in the class definition using the
keyword static in its ____. -ANSWER ✔✔heading


class rectangleType
{
public:
void setLengthWidth(double x, double y);
//Postcondition: length = x; width = y;
void print() const;

, //Output length and width;
double area();
//Calculate and return the area of the rectangle;
double perimeter();
//Calculate and return the parameter;
rectangleType();
//Postcondition: length = 0; width = 0;
rectangleType(double x, double y);
//Postcondition: length = x; width = y;


private:


double length;
double width;
};




Consider the accompanying class definition, and the declaration:


rectangleType bigRect;




Which of the following statements is correct? -ANSWER ✔✔bigRect.print();


class secretType

Document information

Uploaded on
October 13, 2025
Number of pages
27
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers
$20.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.
TESTSMASTER
3.8
(23)
Sold
107
Followers
2
Items
12280
Last sold
1 month 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