Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. What templates are and how to use them as a client (e.g. create a vector of s

ID: 3845302 • Letter: 1

Question

1. What templates are and how to use them as a client (e.g. create a vector of strings and use it). Very basic information. You will NOT be asked to use a queue, set, or map but you should have some idea what they are.

2. What exceptions are and the very basics (try/catch/throw

Functions:
3.What is a pass by value and pass by reference?

4.How to write a function that takes object arguments (e.g. a Point object, or vector of Points) and uses the objects or modifies them in the function? How to return an object from a function (e.g. return a string, a Point or a vector of strings/Points)?

5.How to write a function that takes an array argument and uses the array or modifies it. Be comfortable with arrays of objects (e.g. an array of Point objects)?

Explanation / Answer

1.

2.

exception is an object that wraps an error event that occurred within a method and contains:

try:

Statement(s) where an error can occur. Can be a compound statement.

catch:

If an exception occurs when processing the Try block, each Catch statement is examined in textual order to determine whether it handles the exception, with exception representing the exception that has been thrown.

throw:

An example of a runtime exception is NullPointerException , which occurs when a method tries to access a member of an object through a null reference. The section Unchecked Exceptions — The Controversy discusses why most applications shouldn't throw runtime exceptions or subclass RuntimeException

3.

Pass by Value:

Pass by value means you are making a copy in memory of the actual parameter's value that is passed in, a copy of the contents of the actual parameter. Use pass by value when when you are only "using" the parameter for some computation.

Pass by Reference:

In pass by reference a copy of the address of the actual parameter is stored. Use pass by reference when you are changing the parameter passed in by the client program.