CSCI 240 Final Exam Questions and
Correct Verified Answers Latest
Version
The class X contains two data members: an integer called xVal and a float
called xPerc. Which of the following is NOT a valid prototype for the class
definition for X?
a. void X( int, float );
b. void setxVal( int );
c. float getxPerc();
d. X( int, float );
e. void printX();
✓ a. void X( int, float );
An instance of a class is known as a/an .
a. variable
b. method
c. object
,d. thing
✓ c. object
The :: operator is used to associate a method with a specific class.
a. true
b. false
✓ a. true
Which of the following statements (a-d) about classes is true?
a. A class can contain both data members and methods
b. The members of a class may be private or public
c. The name of the constructor is always the same as the name of the class
d. The class definition contains prototype statements for the methods
e. All of the statements (a-d) are true.
✓ e. All of the statements (a-d) are true.
If a string will need room for 25 characters, how should it be defined so that it
will be a valid string?
,a. char mstr[25];
b. char mstr[24];
c. char mstr[26];
d. char mstr[];
✓ c. mchar mstr[26];
Which mof mthe mfollowing mstring mfunctions mwill mALWAYS mproduce ma mvalid mstring
after mexecution?
m
a. strcpy
b. strcat
c. Both mof mthe mfunctions m(a-b) mwill mproduce ma mvalid mstring
✓ c. mBoth mof mthe mfunctions m(a-b) mwill mproduce ma mvalid mstring
The mnull mterminator mis m .
a. used mto madvance mto ma mnew mline mwhen mexecuting ma mcout mstatement
b. represented mas m'\0'
Master01 m | m September, m 2024/2025 m | m Latest m update
, 1 m| mP ma mg me m | m© mcopyright m2024/2025 m| mGrade mA+
c. used mto mend ma mvalid mstring
d. a mmovie mstarring mArnold mSchwarzenegger
e. All mof mthe mstatements m(a-d) mare mcorrect
f. Only mstatements mb mand mc mare mcorrect
✓ f. mOnly mstatements mb mand mc mare mcorrect.
Which mof mthe mfollowing mis mthe mcorrect mdefinition mfor ma mvariable mcalled mdblRef
that mcan mhold ma mreference mto mthe mdouble mvariable mdblNum?
m
a. double mdblRef m= mdblNum;
b. double m *dblRef m = m &dblNum;
c. double m&dblRef m= mdblNum;
d. double m&dblRef;
✓ c. mdouble m&dblRef m= mdblNum;
Which mof mthe mfollowing mstatements m(a-d) mare mtrue mif mthe mfollowing mlines mof
code mare mexecuted?
m
int mG m= m17;
int m&H m= mG;
Master01 m | m September, m 2024/2025 m | m Latest m update