Final Exam Review Notes - CISC 2000/2010

Final Exam Logistics

  • The final exam is a written exam only.

  • It is scheduled for Thursday, May 8, from 9:30 AM to 11:30 AM.

Written Exam Format

  • The exam will consist of a combination of question types:

    • Fill in the blank

    • True/false

    • Code samples

    • Multiple choice

    • Short answer questions

  • You should be prepared to answer questions dealing with:

    • Syntax and explanation of topics

    • Code analysis

    • Writing short functions (e.g., constructors, mutators, and accessors)

    • Tracing programs to determine their outputs

  • The topics covered will primarily focus on material from after the midterm exam.

  • The exam is closed book. Scratch paper will be allowed.

Topics to Study

Pre-midterm Material

  • Computer Science is cumulative, so understanding of functions, arrays, etc., is necessary.

  • The final exam questions will focus on material from the second half of the semester.

  • Review earlier chapters based on your comfort level with the material.

Classes

  • Defining Classes and Member Variables and Functions

  • Public vs. Private vs. Protected access modifiers

  • Constructors

  • Mutator and Accessor Functions (getters and setters)

  • Writing and Designing Abstract Data Types (ADTs)

    • Interface and Implementation Files

Inheritance

  • Four Key Concepts of Object-Oriented Programming

  • Base Classes and Derived Classes

    • Constructors in Derived Classes

    • Inheritance

    • Function Redefinition vs. Function Overloading

    • Accessing Redefined Base Class Functions

  • Polymorphism

    • Virtual Functions

    • Extended Type Compatibility (Coercion)

Inheritance Details

Use of Private Member Variables from the Base Class
  • A derived class object has full access to all public member variables of the base class.

  • However, it does NOT have direct access to any of the private members of the base class.

    • Example:

      • SavingsAccount sa;

      • sa.interestRate; // No Access (assuming interestRate is private)

      • sa.getInterestRate(); // Works properly (assuming getInterestRate() is public)

Friends, Overloaded Operators, and Arrays in Classes

  • Friend Functions

  • The const Parameter Modifier

  • Operator Overloading

    • Rules on Overloading Operators

    • Unary Operators vs. Binary Operators

    • Overloading >> and << Operators

  • Classes and Dynamic Arrays

    • The Big Three: Destructors, Copy Constructors, and Assignment Operator

Templates

  • Templates for Algorithm Abstraction

    • How to define a function template

    • Template prefix (class/typename, type parameter)

Iterators

  • How iterators work

  • Getting iterators from containers

  • Types of iterators

Exceptions

  • What happens when exceptions are thrown

  • How exceptions get handled (or not)

Review Questions

Object-Oriented Programming

  • What are the different files used to organize source code, especially for classes?

  • What are the four key concepts that define object-oriented programming?

  • What is encapsulation?

Classes

  • What are getters and setters used for?

  • What special variable refers to the current object within member functions? (this pointer)

  • What are the three access modifiers and how do they affect members of a class? (public, private, protected)

  • How does class scoping work? Can you have different variables with the same name in two different classes within the same program?

  • When are constructors and destructors called?

  • Be ready to write a constructor (both default and custom constructors).

  • Be ready to write accessor (getter) and mutator (setter) functions.

Inheritance

  • What functions are automatically inherited, and which are not?

  • Why would you write a derived class?

  • How many levels of inheritance are allowed?

  • What access do child classes have to parent class members? (public, protected, private)

  • What does the “is-a” relationship mean?

  • What does it mean to redefine a member function? What do you have to do to redefine a member function?

Polymorphism

  • What is polymorphism, and how is it implemented in C++?

  • What is late-binding polymorphism? How is it declared? (using virtual functions)

Operator Overloading

  • Overloaded operators require that at least one argument be what? (an object of the class or a reference to an object of the class)

  • Which operators cannot be overloaded?

  • Which operators must be member functions?

  • Which operators cannot be member functions? What kind of function will they be then? (friend functions)

  • What properties of an operator cannot be changed when overloading operators? (precedence, associativity, number of operands)

The Big Three

  • What are the "Big Three" functions, and when do you need them?

    • Destructor: Called when an object goes out of scope or is explicitly deleted. Releases resources held by the object (e.g., memory allocated with new).

    • Copy Constructor: Creates a new object as a deep copy of an existing object.

    • Copy Assignment Operator: Assigns the values of one object to another object of the same class. Handles deep copying.

The Big Three Details
  • Destructor: This special member function is automatically called when an object of the class goes out of scope, or when the object is explicitly deleted. Its primary purpose is to release any resources held by the object, like memory allocated with new or other system resources.

  • Copy Constructor: This constructor is responsible for creating a new object that is a deep copy of an existing object. A deep copy ensures that the new object has its own independent copy of the data, rather than just pointing to the same memory location as the original.

  • Copy Assignment Operator: This operator (overloaded using operator=) is used to assign the values of one object to another object of the same class. Like the copy constructor, it also needs to handle deep copying to avoid issues with shared resources.

Templates

  • How do you indicate a generic/template function? (using template <typename T> or template <class T>).

  • How do you indicate a generic/template class? (using template <typename T> or template <class T> before the class definition).

  • How many template parameters are allowed? (Multiple template parameters are allowed).

Iterators

  • What kinds of iterators are there?

  • How do you get an iterator?

  • How do you advance or go backwards in a sequence?

Exceptions

  • What happens when an exception is thrown?

  • How many catch clauses can you have? (Multiple catch clauses for different exception types).

  • What happens if an exception is thrown and it’s never caught? (The program terminates).