CECS 342 Midterm Study Guide

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

1/14

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 7:02 PM on 10/15/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

15 Terms

1
New cards

For any custom class that dynamically allocates memory, what member functions must be supplied?

a) Copy constructor, constructor, destructor

b) Constructor, destructor, operator==

c) Assignment operator, Copy constructor, destructor

d) Copy constructor, destructor

c) Assignment operator, Copy constructor, destructor

2
New cards

If you do not define a destructor function for your custom class:

a) You will get a warning when you compile your program

b) The C++ compiler defines a default destructor for you

c) All of these

d) Your class may leave memory leaks from strings and vectors used as data members

b) The C++ compiler defines a default destructor for you

3
New cards

What can be said about the following statement?

"The scope of a variable is limited to the clause in which it appears."

a) the statement is theoretically true, but the implementation of prolog does not enforce this concept.

b) the statement is false - prolog variables do not have "scope" in the traditional computer language sense.

c) that is false. Prolog makes use of global variables so the clauses can pass information to each other

d) that statement is true.

d) that statement is true.

4
New cards

Prolog and other logic languages are based on...

a) boolean binary

b) predicate calculus

c) logistical nightmares

d) formal logic

b) predicate calculus

5
New cards

What can be said about the following prolog statement:

grandparent(G, C) :- parent(G,P), parent(P, C).

a) it is a rule

b) it is a fact

c) it is a query

d) it is a goal

a) it is a rule

6
New cards

What can be said about this prolog statement:

parent(steve, landon).

a) it is hard to raise kids these days

b) it is a fact

c) it is a goal

d) it is a rule

b) it is a fact

7
New cards

What term is used to describe how the prolog interpreter works in order to prove a goal?

a) depth-first recursion

b) backward chaining

c) random tagging

d) forward linking

b) backward chaining

8
New cards

The body of a Horn Clause...

a) is a list of terms.

b) is not transmittable

c) is a single term.

d) The correct answer is not shown.

a) is a list of terms.

9
New cards

Is this function tail recursive?

int fibo(int n, int n1=1, int n2=1)

{

if (n == 0) return n2;

if (n == 1) return n1 + n2;

return fibo(n-1, n2, n1+n2);

}

a) True

b) False

a) True

10
New cards

The head of a Horn Clause...

a) The correct answer is not listed.

b) is a list of terms

c) is inverted when called

d) is a single term

d) is a single term

11
New cards

Is this function tail recursive?

int fibo(int n, int n1=1, int n2=1)

{

if (n == 0) return n2;

if (n == 1) return n1 + n2;

int result = fibo(n-1, n2, n1+n2);

return result

}

a) True

b) False

b) False

12
New cards

What is true about Horn Clauses?

a) They have a head and a body

b) It's Santa Clauses brother

c) They are hard to implement

d) They are tail-recursive

a) They have a head and a body

13
New cards

*Does not remember entirely* Every C++ program must have a header file.

a) True

b) False

a) True?

14
New cards

*Does not remember entirely*

This code runs properly:

#include

int main() {

cout << "Hello World!";

return 0;

}

a) True

b) False

a) False?

Needs "using namespace std;" after the "#include ___" part since you're not using std::cout << "Hello World!";

15
New cards

*Does not remember entirely*

This code runs properly:

#include

int main() {

std::cout << "Hello World!";

return 0;

}

a) True

b) False

b) False?

Ran in onlinegdb and gave error message