Jump to content

Old program exam


CoolMaster

Recommended Posts

Basically we have an exam tommorow and i've been studying up :-D

it's a written exam

and he gave us the old test, but not the old answers lol? and since we dont have a book it's like uh ok lol

 

i figured tho if I could get the answers i could study, im gonna fill in what i know, (well slowly edit it until it's correct) and if anyone could help out i'd thank them alot. just kinda look over and point out the ones I got wrong, or missed completely?

 

this is the OLD exam btw, dont worry not trying to get yall to do the exam lol just knowing the old exam helps alot

 

and btw I def dont know all of these, im just trying my best

 

 

 

CS215 Fall 2006 Exam 1

 

Name: ______________________________________________ Section: _________________

 

Written exam closed book, closed notes, NO CALCULATORS, total 80 points.

 

Written Score: _____________ / 80

 

Lab Score: _____________ / 20

 

Exam 1 Total: _____________ / 100

 

True/False (2 points each)

Indicate whether the sentence or statement is true or false.

 

__F__ 1. A struct can be passed as a parameter to a function by value or by reference.

 

__F__ 2. Binary numbers are used in computers because binary allows numeric calculations to be done faster and easier.

 

__F__ 3. A function’s return value can be an instance of a class (class object).

 

__F__ 4. Members of a derived class can directly access the private members of the base class.

 

_T___ 5. A derived class and its base class cannot have member functions with the same name.

 

__F__ 6. When the type definition of a struct is processed, no memory is allocated for a struct of that type.

 

__F__ 7. Much like an array, a struct is considered a homogeneous data structure.

 

__T__ 8. A struct cannot have a member which is another struct.

 

Multiple Choice (2 points each)

Identify the letter of the choice that best completes the statement or answers the question. Each question has only ONE correct answer.

 

_D___ 9. Assume that alpha and beta are Cstrings of size 20. Which of the following statements is illegal in C++?

a. cin>>alpha; d. alpha = beta;

b. if (strcmp(alpha, beta)) e. c and d

c. alpha[0] = 'C';

 

 

 

__D__ 10. In C++, the ____ symbol is an operator, called the member access operator.

a. : (colon) c. , (comma)

b. . (dot) d. $ (dollar sign)

 

 

 

_A or B?___ 11. Which of the following is true about classes and structs?

a. By default, all members of a struct are public and all members of a class are private.

b. A struct variable is passed by value only, and a class variable is passed by reference only.

c. Assignment operator is allowed on class variables, but not on struct variables.

d. You cannot use the member access specifier private in a struct.

 

 

 

 

__D__ 12. Which of the following relationship types most accurately describes the concept of class containment?

a. is a c. wants a

b. was a

d. has a

 

 

___D?_ 13. The #ifndef, #define, #endif statements that are put in files to be included are used to:

a. tell the compiler that this is a definition of a structure or class, and does not include executable statements c. help debug the program

b. ensure that the file is included only once d. all of the above

 

 

 

___E_ 14. Suppose that the class declaration of SomeClass includes the following function prototype.

 

bool equal( /* in */ SomeClass anotherObject );

 

Which of the following tests in the client code correctly compares two class objects alpha and beta?

 

a. if (alpha == beta) d. if (alpha.equal.beta)

b. if (alpha.equal(beta)) e. if (equal(alpha).beta)

c. if (equal(alpha, beta))

 

 

 

__D__ 15. Which of the following is a valid definition of the derived class bClass?

a. class aClass: public bClass

{

...

};

 

b. class bClass: public aClass

{

...

};

 

c. class aClass::bClass

{

...

};

 

d. class bClass::aClass

{

...

};

 

 

 

 

 

 

 

 

 

 

 

 

 

 

___A_ 16. Consider the following statements.

 

struct studentType1

{

string name;

int ID;

double gpa;

};

 

studentType1 student1, student2;

 

struct studentType2

{

string name;

int ID;

double gpa;

};

 

studentType2 student3, student4;

 

Which of the following statements is valid in C++?

a. student2 = student3;

b. student3 = student4;

c. student1.ID = student3.ID;

d. b and c

e. a, b, and c

 

 

 

__B__ 17. If you want to modify a parameter passed to a function, it should be passed by ________.

a. reference c. index

b. value d. constant

 

 

 

__D__ 18. The specification (definition) file of a class has an extension _____.

a. imp c. exe

b. h d. cpp

 

 

 

_(no clue)___ 19. If a C++ program is written and compiled on an Intel machine, what part of the program must be transfered to a PowerPC machine for the program to run?

a. the program executable c. the C++ source files

b. the compiled object code

d. all of the above

 

 

__D(their diff classes correct?)__ 20. In the object-oriented design of a university, suppose that "person," "student," and "address" have been identified as objects. Focusing on the student object, how does it relate to the person object?

a. a derived class d. an independent class

b. a base class e. none of the above

c. a contained class

 

 

 

__C__ 21. To guarantee that the data members of a class object are initialized upon creation, you use special member functions known as ________.

a. accessors c. constructors

b. mutators d. destructors

 

 

 

 

____ 22. Consider the following class definitions.

 

class bClass

{

public:

void print() const;

bClass();

bClass(double a)

private:

double z;

};

 

class dClass: public bClass

{

public:

void print() const;

dClass();

dClass(double a, double b, double c);

private:

double x;

double y;

};

 

Which of the following dClass constructor definitions is valid in C++?

a. dClass::dClass(double a, double b, double c)

: bClass

Edited by CoolMaster

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...