1/34
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No study sessions yet.
What is printed to the screen when this program runs? (Global int x=10; void print(int y){cout << y << ":" << x;} main(){int x=5; print(x);})
10:10
10:5
5:5
5:10
5:10
Which function prototype would satisfy the line: Z = X + Y; (Where X, Y, Z are BigInt)?
int operator+(int, int, int);
BigInt BigInt::operator+(BigInt, BigInt);
BigInt operator+(BigInt, BigInt);
BigInt BigInt::operator+(int);
BigInt operator+(BigInt, BigInt);
What is printed to the screen when this program is run? (toss throws 42; catch(int); prints "world-", then "awesome-")
hello-world-awesome
world-awesome
the correct answer is not listed
hello-awesome
world-awesome-
Consider the following program. What is printed? (Global x=10; print(y) prints y:x; main defines x=17, calls print(x))
17:10
10:5
10:17
There is a compiler error because there are too many x variables.
17:10
What is printed to the screen when this program is run? (toss throws 42 (int); catch(const char * s);)
Nothing is printed
awesome
hello-awesome
hello-world-awesome
Nothing is printed
What is the BEST programming language EVER? (Code prints ASCII char 67, then +, +)
C++
Python (yeah, right...)
FORTRAN
HammerHead
C++
What is the output of the following program: swap(int &x, int y) { int temp=x; x=y; y=temp; } main() { a=10, b=20; swap(a,b); cout a,b; }
20, 20
10,10
10,20
20,10
20,20
Where does the variable x live? (Global variable defined at top of file)
on the heap
on the stack
on the run
data segment
data segment
Where does the variable y live? (static int y = 20 inside a function)
on the heap
on the stack
on the run
data segment
data segment
Where does the variable ptr live? (int *ptr inside a function)
on the heap
on the stack
on the run
data segment
on the stack
Where does the variable z live? (void scope(int z) - parameter)
on the heap
on the stack
on the run
data segment
on the stack
What will be printed on the screen if I type this command sequence: more numbers.dat | tail -100 | head -25 | tail -1 (File has 1-100 sorted)?
25
none
21
20
25
int A[]={0,1,2,3,4,5}; int *ptr=A; How would I print 5 to the screen?
cout << ptr + 5;
cout << ptr[5];
cout << *ptr[5];
cout << ptr 5;
cout << ptr[5];
What is wrong with the following C++ program: int ptr; int ptr2=&y; y=x; ptr=&x;
nothing is wrong
Where does the variable ptr[5] live? (int *ptr = new int[10]; accessing the array memory)
on the stack
on the heap
on the move
on the spot
on the heap
int a=10; int *ptr = &a; cout << ptr; What is printed out?
the number 10
the contents of a
the memory address of a
the memory address of ptr
the memory address of a
How many numbers will the printArray() function actually print out? (void printArray(int n[]) loop using n.size())
all the numbers in the array
1
10
the correct answer is not listed
the correct answer is not listed (Arrays do not have .size())
Consider the following program. What is the output? (Vector push_back i5 for i 0-9; cout << (it+3))
3
5
it will not compile
15
15
What can be understood from the following Linux command: time sort numbers.dat ... real 0m1.593s?
The command took about 6.9 seconds to run (1.6 + 5.1+0.2)
The correct answer is not listed
The command took about 1.6 seconds to run
The command took about 0.2 seconds to run
The command took about 5.1 seconds to run
The command took about 1.6 seconds to run
How can an object refer to itself in C++?
myself
me
self
this
this
How many characters are there in the standard ASCII table?
256
128
127
255
128
Where does dynamic memory allocation take place?
heap
text segment
stack
data segment
heap
char word [10] = "matrix"; cout << strlen(word); What will be printed?
correct answer is not listed
6
matrix
10
6
In which c++ library is strlen() found?
correct answer not listed
<cstring>
<strlen>
<string>
<cstring>
Which of the answers print the same correct output as A[index]?
cout << A + index:
cout << &A[index];
cout << (A + index);
cout <<*(A + index);
cout << *(A + index);
What is the passing mode used in the function void func(char *ptr)?
pass by value
pass by linkage
pass by reference
pass by touchdown
pass by value
This program will compile and run just fine: cout << "Hello World"; (No using namespace std or std::)
true or false
False
Vector deck; Card c1; What statement will add the card to the deck?
deck.add(c1);
deck = c1:
deck.push_back(c1);
deck.put(c1);
deck.push_back(c1);
Which one of the following operator cannot be overloaded in C++?
operator==
The correct answer is not listed
operator[]
operator&
operator+
The correct answer is not listed (operators like :: or . cannot, but options were ==, [], +, &)
What function is being called: BigInt Y = X++;
BigInt operator++(int);
BigInt BigInt::operator++();
BigInt BigInt::operator++(int);
BigInt operator++();
BigInt operator++(int);
When using friend functions for operator overloading, which of the following statements is true?
Friend functions can only access public members of a class
Friend functions are member functions of a class
Friend functions can access any data member of a class.
Friend functions cannot be used for operator overloading
Friend functions can access any data member of a class.
Which of the following non-member functions is valid syntax for overloading the addition operator (+)?
BigInt operator + (BigInt a, BigInt b)
void operator + (BigInt a, BigInt b)
void operator + (BigInt a)
BigInt operator + (BigInt a)
BigInt operator + (BigInt a, BigInt b)
Which of the following member functions is valid syntax for overloading the operator%() in C++?
void BigInt::operator % (BigInt a, BigInt b)
void BigInt::operator % (BigInt a)
BigInt BigInt::operator % (BigInt a)
BigInt BigInt::operator % (BigInt a, BigInt b)
BigInt BigInt::operator % (BigInt a)
What is the output of the following program: vector v; auto start=v.begin(), end=v.end(); if(start==end) cout "happy" else "sad"?
sad
happy
begin
start
happy
Which value will be removed from the vector? v={1,2,3,4,5,6}; v.erase(v.begin()+3);
3
4
5
6
4