Computer Programming 2 Final Study Guide

0.0(0)
studied byStudied by 0 people
GameKnowt Play
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/88

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

89 Terms

1
New cards

What’s the difference between a pointer and pointer variable?

A pointer is a variable that stores the memory address of another variable, whereas the pointer variable is a variable that holds the address.

2
New cards

What operator allows you to access the item that the pointer points to?

Indirection ( * )

3
New cards

The _____ key word was introduced to represent the address 0.

nullptr

4
New cards

True or False: Pointers can mix data types.

False

5
New cards

What is Dynamic Memory Allocation

A process that can allocate storage for a variable while a program is running.

6
New cards

The ____ operator is used to allocate memory.

new

7
New cards

What key is used to free dynamic memory.

delete

8
New cards

Structure

A C++ construct that allows multiple variables to be grouped together

9
New cards

The ____ operator refers to members of struct variables

dot (.)

10
New cards

What operator assigns the address

&

11
New cards

Enumerated Data Type

A programmer defined data type that consists of values as enumerators, which represent integer constants.

12
New cards

Class

Similar to a struct, but variables and functions in the class can have different properties

13
New cards

What is an object?

An instance of a class, in the same way that a variable can be an instance of a struct

14
New cards

Explain the relationship between classes and objects

A class is like a blueprint and objects are like houses built from the blueprint

15
New cards

Attributes

Members of a class

16
New cards

Methods or behaviors

Member functions of a class

17
New cards

What is const?

const appears after the parentheses in a member function declaration specifies that the function will not change any data in the calling object.

18
New cards

Public members

can be accessed by functions outside of the class

19
New cards

Private members

can only be called or accessed by functions that are members of the class

20
New cards

Difference between Mutators and Accessors

Mutators stores the value in a private member variable. Also known as a setter. Accessors retrieves a value from a private member variable. Also known as the getter.

21
New cards

A constructor is a function that is automatically called when an object is

created

22
New cards

A destructor is a member function that is automatically called when an object is

destroyed

23
New cards

True or false: Overloading Constructors can have more than one constructor

True

24
New cards

When a constructor is calls another constructor in the same class is called

constructor delegation

25
New cards

Default constructor

a constructor that takes no arguments.

26
New cards

A ____ member function can only be called by another member function

private

27
New cards

UML stands for

Unified Modeling Language

28
New cards

A member variable in a class where each object has its own copy is called

instance variable

29
New cards

When one variable is shared among all objects of a class is called

static variable

30
New cards

A ____ is a function or class that is not a member of a class, but has access to private members of the class

Friend

31
New cards

A _______ is a special constructor used when a newly created object is initialized to the data of another object of the same class

Copy Constructors

32
New cards

The ____ pointer is predefined pointer available to a class’s member functions

this

33
New cards

Explain aggregation and its role

A class that is a member of a class that supports the modeling of ‘has a’ between classes - enclosing class ‘has a’ enclosed class

34
New cards

Name two implements that any class that contains a pointer or reference to an outside piece of data.

Copy constructor and copy assignment operator

35
New cards

The _____ keyword declares which default operations that you want the compiler to automatically provide

default

36
New cards

The ___ keyword declares which default operations you do not want the compiler to automatically provide.

delete

37
New cards

_____ provides a way to create a new class from an existing class

Inheritance

38
New cards

The base class is also known as

Parent class

39
New cards

The derived class is also known

child class

40
New cards

Which is the base class? class UnderGrad : public student

student

41
New cards

Which is the derived class? class box : public rectangle

box

42
New cards

like private, but accessible by objects of derived class

protected

43
New cards

Determines how private, protected, and public members of base class are inherited by the derived class

class access specification

44
New cards

Object of the derived class that can be treated as object of the base class

public

45
New cards

protected

Restrictive than public, but allows derived classes to know details of parents

46
New cards

private

prevents objects of the derived class from being treated as objects of the base class

47
New cards

Name the constructors that cannot be inherited

Default, Copy, and Move Constructor

48
New cards

Virtual member function

Is a function in a base class that expects to be redefined in the derived class

49
New cards

A base class can be derived from another base class

Class Hierarchies

50
New cards

Dynamic binding

functions bound at run time to function that they call

51
New cards

Static Binding

A function bound at compile time

52
New cards

The ____ key word tells the compiler that the function is supposed to override a function in the base class

override

53
New cards

The ____ key word cannot be overridden in a derived class

final

54
New cards

A class that can have no objects

Abstract base class

55
New cards

A derived class that can have have more than one base class

Multiple Inheritance

56
New cards

Exception

An object or value that signals an error

57
New cards

Explain the catch and throw exceptions

Throw sends a signal that an error has occurred and catch process the exception; interpret the signal

58
New cards
59
New cards

When is the bad_alloc exception thrown?

When the new operator fails to allocate memory.

60
New cards

A pattern for a function that can work with many data types

Function template

61
New cards

What does STL stand for?

Standard Template Library

62
New cards

Give a short answer for the container, iterator and algorithms templates

Containers class templates for objects that store and organize data. Iterators behave like pointers, and used to access individual data elements in a container. Algorithms perform various operations on elements of containers.

63
New cards

A set of data structures (nodes) that contain references to other data structures

Linked list

64
New cards

Node contains

data and a pointer

65
New cards

Last node points to

null (address 0)

66
New cards

An empty list

is a list that contains 0 nodes

67
New cards

A LIFO (last in, first out) data structure

Stack

68
New cards

True or False: A stack can hold char values

True

69
New cards

A FIFO (first in, first out) data structure.

Queue

70
New cards

Where are elements are added in Queue locations?

rear

71
New cards

Where are elements removed?

Front

72
New cards

Explain the difference between enqueue and dequeue.

Enqueue adds an element to the rear of the queue and dequeue removes an element from the front of a queue

73
New cards
74
New cards

Dynamic Queues

Similar to stack, a queue can be implemented using a linked list

75
New cards

A function contains a call to itself

recursive

76
New cards

What happens when a recursive function is called?

A new copy runs with new instances of parameters and local variables created

77
New cards

True or false: Recursive members cannot be members of a linked list class

False

78
New cards
79
New cards
80
New cards
81
New cards
82
New cards
83
New cards
84
New cards
85
New cards
86
New cards
87
New cards
88
New cards
89
New cards