Schedule‎ > ‎

Quiz 4 Prep

Quiz 4 Preparation   CS-11 (50 pts)


1)      C++ Vocabulary:  Be able to define these C++ terms in your own words (Lesson 9):

a.      Encapsulation

b.      Object oriented programming

c.      Abstraction

d.      Access control:  public,  private and protected (focus on public & private, not protected)

e.      Constructor – what is it used for?  How do you figure out which method it is?

f.       Default Constructor

g.  What is an accessor method?  What is a mutator method?

h.      What is an instance (aka object)?  How do you create an instance/object?

i.      What is the difference between an interface and an implementation (aka definition)?  (See comments in Key Sample Code studentConst.cpp)

j.    What is a class method or member function?

2)     Be able to write a class interface,  implementation and main() given specifications like these: (Lesson 9 – and look at Key Sample Code)

        Write a Class Student such that:

a.      Give it 3 variables like name, height, major

b.      Write at least 2 constructors (one of which is a default constructor). 

c.      Write a getter and a setter for each variable. 

d.      Create 1 additional method for your student of your choice.

e.      create at least 2 instances of your class Student (one from your default constructor)

f.       Change something about two of your instances.

g.      Call the method you created in step d. above

h.      Print out information about each of your students.

i.         See Class Student in Key Sample Code for a solution


3)      Write the code to declare a vector of floats named myDoubles which is initially empty. (10.2.2)


4)      Write the code to add 3  doubles to your vector:    2.3   4.5   6.7  (10.2)



5)      Write the code to print out these 3 floats from your vector.  You must use the vector size function.   (10.2.4)




6)      Write the pseudocode to find a value in a vector of ints.  (10.3.2)





7)     Write the pseudocode to delete a value from a vector when you are given the index position to delete in variable int pos  (10.3.3)






8)      What’s the difference between a list where order matters and where order doesn’t matter?  You can give an example of each.  (10.3.3)




9)     Why do we care if a list is ordered or not?  (10.3.3)




10)  Write the code to make a vector of instances of your class Student from earlier in this Quiz Prep.   (10.4)

a.      You do not have to  rewrite your class Student here.  Assume it is already declared and defined.  Just write the main() code.

b.      Put at least 3 instances of Students in your vector

c.      Change the name of the last student in your vector

d.      Change the height of the first student in your vector

e.      Print out information about each student in your vector from a non-member function which takes your vector as a parameter (10.4.2)