Final Study Guide

 

CS 202: Programming Systems

 

#1) The final will be comprehensive, covering C++, Java, and OOP. Don’t forget debuggers and your data structures?!

 

      For C++, emphasis will be placed on single inheritance, dynamic memory. Dynamic binding, static members, constant member functions, operator overloading, copy constructors, and abstract classes. A great place to study is to review your midterm!

 

      For debuggers, expect to be able to answer general questions on debuggers.

 

      For Java, know the main differences between C++ and Java. Be able to take a C++ program and indicate what changes you would make if it were solved in Java. Understand how to do: inheritance, dynamic binding, abstract classes, and create objects of classes.

 

      For OOP, expect to be able to solve problems with a combination of is-a and has-a relationships.

 

 

#2) Focus will be placed on character strings, pointers, structures,  and how to build and traverse various data structures (such as linked lists, binary search trees, or arrays of linked lists) in both C++ and Java.

 

#3) Here are some sample study questions:

 

  1. Assume you are writing a string class where the private data member is a char *.

·        Write the prototype statements for the += and + operators, used to concatenate two strings together.

·        Implement the assignment operator

·        Or, know the prototypes for the [], ++, = operators

·        What is the prototype for the copy constructor

 

  1. Summarize the “rules” that you have learned about how to overload operators. Answer the question in regard to the following:

Return type, Argument List:, Overload as a Member:, Overload as a Const Member, Virtual keyword for Operators.

 

  1. How do you perform dynamic binding with operators that are not overloaded as members?
  2. What is the difference conceptually between an abstract base class and just a base class?
  3. Why do some operators return by value?
  4. Give an example where dynamic binding would make sense within a hierarchy.
  5. Write a C++ function to copy a binary search tree using inorder traversal and place each item at the end of an existing linear linked list. The linear linked list may have data already in it.  (Assume the data is weather information that has been collected – details will be given on a real exam – for practice come up with your own conclusion!)

 

*** Make this Object Oriented! ***

*** Perform a deep copy of the data and show your memory allocation ***

*** Make sure to create a class for the data and the node ***

 

  1. Re-write the above function using Java for practice!
  2. If you have time, and want to practice more – modify questions #g and #h to:
  3. Now write both a C++ and a Java function to remove the last node from a linear linked list (given a head pointer – but not a tail pointer)
  4. When programming in Java, how can we perform a deep copy of one object into another?
  5.  What features in Java, if used, are not “object oriented”?
  6. What is the difference between an abstract class and an interface?
  7. Create an Object Oriented design (you do not need to provide any code for this) for the following problem. Draw what classes you will need, and indicate where there are “is a” versus “has a” relationships. 

                 

You want to represent software for the automobile dealers in our area: Chevrolet, Ford, and BMW. Chevy and Ford have Trucks, SUVs, Sedans, and Economy cars, BMW has Sedans and Luxury cars. All cars have a few things in common: fuel economy rating, number of passengers allowed, as well as other things. All types have a few things that are different – Luxury cars have a list of features that are built into the cars (heated seats, 8 airbags, etc.), whereas economy cars are striped down, with only a few features that can be added on (e.g., manual versus electric windows). A dealer can sell a car, get new cars in as inventory, or trade a car with a broker.