CSCE 240 Real Study guide EXAM 2

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/53

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 1:41 AM on 10/16/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

54 Terms

1
New cards

What is an array in C++?

A fixed-size collection of values of one type stored in contiguous memory.

2
New cards

What is the first index of a C++ array?

0.

3
New cards

What are the valid indexes of an array with size n?

0 through n - 1.

4
New cards

What does int x[5] = {3, 7, 2}; initialize x to?

{3, 7, 2, 0, 0}.

5
New cards

What does int x[] = {3, 7, 2}; make the size?

3.

6
New cards

What happens when an array index is outside its valid range?

Undefined behavior; it may corrupt memory, appear to work, or crash.

7
New cards

What does the name of an array generally represent in an expression?

The address of its first element.

8
New cards

What does x[4] mean?

The value at index 4, equivalent to *(x + 4).

9
New cards

How are multidimensional arrays declared?

With multiple bracketed dimensions, such as int x[3][8].

10
New cards

How are multidimensional arrays initialized?

With a list of row lists, such as {{1, 2}, {3, 4}}.

11
New cards

Which dimensions need sizes in a multidimensional array parameter?

Every dimension except the first.

12
New cards

What is a C-string?

A character array terminated by the null character \0.

13
New cards

What is the size of char word[] = "Hello";?

6, including the terminating \0.

14
New cards

What does cout << word do for a C-string?

Prints characters until it reaches \0.

15
New cards

What is the danger of cin >> word for a character array?

Input can exceed the array's capacity and overrun its bounds.

16
New cards

How are one-dimensional arrays passed to functions?

Use an empty bracket parameter and pass the array name, such as void f(const int a[], int size).

17
New cards

Does an array parameter copy the entire array?

No. The function receives access to the caller's array.

18
New cards

Why use const in an array parameter?

To prevent the function from modifying the caller's array.

19
New cards

What is linear search?

Checking elements one at a time until the target is found or the array ends.

20
New cards

What condition is required for binary search?

The array must be sorted.

21
New cards

What does binary search do after checking the middle element?

It discards the half that cannot contain the target.

22
New cards

What does bubble sort do?

Repeatedly swaps adjacent out-of-order elements.

23
New cards

What does selection sort do?

Finds the smallest remaining element and swaps it into the next position.

24
New cards

What does insertion sort do?

Inserts the next element into the already-sorted portion.

25
New cards

What is a pointer?

A variable that stores a memory address.

26
New cards

What does &x produce?

The address of x.

27
New cards

What does *p produce?

The value stored at the address held by p.

28
New cards

If p points to x, what does *p = 9 do?

It changes x to 9.

29
New cards

What does adding 1 to a pointer do?

Moves it to the next object of its pointed-to type.

30
New cards

What is the relationship between a[i] and *(a + i)?

They access the same array element.

31
New cards

What does const int *p mean?

The pointed-to data cannot be changed through p, but p can point elsewhere.

32
New cards

What does int * const p mean?

p cannot point elsewhere, but the pointed-to data can change through p.

33
New cards

What does const int * const p mean?

Neither the pointer nor the pointed-to data can change through p.

34
New cards

What does new do?

Allocates memory dynamically and returns its address.

35
New cards

When is delete used?

To release one object allocated with new.

36
New cards

When is delete[] used?

To release an array allocated with new[].

37
New cards

What is a memory leak?

Allocated memory that is no longer reachable or released.

38
New cards

What is a structure?

A user-defined type containing data members.

39
New cards

What is the practical default-access difference between struct and class?

struct members are public by default; class members are private by default.

40
New cards

When is the dot operator used?

With an object, such as object.member.

41
New cards

When is the arrow operator used?

With a pointer to an object, such as pointer->member.

42
New cards

What is a constructor?

A special function with the class name, no return type, called when an object is created.

43
New cards

What is a default constructor?

A constructor callable with no arguments.

44
New cards

Why use explicit on a single-argument constructor?

To prevent unwanted implicit conversions.

45
New cards

What is a destructor?

A function named ~ClassName with no arguments or return type, called when an object is destroyed.

46
New cards

Can destructors be overloaded?

No.

47
New cards

What is a constant member function?

A member function declared const that cannot modify its object.

48
New cards

What is an accessor?

A function that returns information from an object.

49
New cards

What is a mutator?

A function that changes an object's data under class control.

50
New cards

What is a friend function?

A non-member function granted access to a class's private or protected members.

51
New cards

What is composition?

A has-a relationship in which one class contains an object of another class.

52
New cards

What is the this pointer?

A pointer to the current object inside a non-static member function.

53
New cards

What is operator overloading?

Giving an operator meaning for a user-defined class type.

54
New cards