1/33
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
What can be said about C++ vs Python?
a) They both allow recursion
b) Python allows recursion but C++ does not.
c) C++ allows recursion but Python does not
d) Neither allows recursion
a) They both allow recursion
What can be said about C++ vs Python?
a) Both languages are interpreted
b) Both languages are compiled
c) The performance of both languages appears to be similar
d) None of these answers are correct
d) None of these answers are correct
All computer languages use compilation to create executable machine code.
a) True
b) False
b) False
What is a regular expression?
a) a character
b) all of these are correct
c) a regular expression followed by a Kleene star
d) the empty string
b) all of these are correct
What is a scanner NOT responsible for?
a) tokenizing source
b) building parse trees
c) saving source locations for error messages
d) removing comments
b) building parse trees
Context Free Grammars will always produce non-ambiguous parse trees
a) True
b) False
b) False
What does CFG stand for?
a) Compound Function Generator
b) None of these are correct
c) Computers Forcing Graphics
d) Compound Fraction Gradients
b) None of these are correct
There are basically 2 types of programming languages: Imperative and Declarative. Which of the following is considered Declarative?
a) Prolog
b) Fortran
c) C++
d) The correct answer is not listed
a) Prolog
What is a clear benefit for compilation?
a) Better diagnostics (error messages)
b) Better performance
c) Less memory use
d) Program is easier to read
b) Better performance
What is the process that divides a program into tokens?
a) interpreting
b) parsing
c) scanning
d) compiling
c) scanning
We talked about the "dangling else" problem in class. This is a thing that only happens in C++.
a) True
b) False
b) False
What does the following code print?
int x = 4;
cout <<< ++x << x << x++ << x;
a) 5566
b) 5556
c) None of these
d) 4567
b) 5556
What String class member function is invoked by the 2nd line of the following code?
String s("Ann");
String t = s;
a) The non-overloaded=operator
b) operator=
c) The copy constructor
d) The default constructor
c) The copy constructor
What is the term for the function in C++ class definition that can deallocate dynamic memory when the object goes out of scope, as in a return from a function which has created a local object?
a) Tilde function
b) Deconstructor
c) Destructor
d) Exit
c) Destructor
What is the correct function prototype to implement an equals comparison operation for a class such as Time?
a) void operator==(Time a, Time b)
b) void ==(Time a, Time b)
c) bool ==(Time a, Time b)
d) bool operator==(Time a, Time b)
d) bool operator==(Time a, Time b)
What if anything is wrong with the following class definition?
class Fraction //represents fractions of the type 1/2, 3/4, 17/1
{
public:
Fraction(int n, int d);
Fraction(int n);
Fraction();
Fraction operator+(Fraction other) const;
Fraction operator-(Fraction other) const;
Fraction operator*(Fraction other) const;
bool operator
a) Nothing is wrong
Given a class Name with member functions get_first and get_last, which of the following functions overloads << so that one can print a name as
Name name("Bjarne Stroustrup");
cout << name << endl;
a) ostream& operator<
b) ostream& operator<
Which of the following is the proper function prototype for the String class copy-constructor?
a) String::String(String this, const String& other)
b) String::String(const String& other)
c) String::String=(const String& other)
d) String::String()
b) String::String(const String& other)
A class can have ____ destructor functions(s) and ____ constructor function(s).
a) one, several
b) one, one
c) many, one
d) several, several
a) one, several
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
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
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.
Prolog and other logic languages are based on...
a) boolean binary
b) predicate calculus
c) logistical nightmares
d) formal logic
b) predicate calculus
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
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
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
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.
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
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
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
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
*Does not remember entirely* Every C++ program must have a header file.
a) True
b) False
a) True?
*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!";
*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