Final+Exam+Sample-2014 -1- (1)
-
Upload
suzanne-cyder -
Category
Documents
-
view
215 -
download
2
Transcript of Final+Exam+Sample-2014 -1- (1)
-
Final Exam Sample Questions CMPS 109 Ira Pohl March 11, 2014
Problem 1.Answer true or false.
a. The operators binary * and integer remainder % have the same
precedence.
b. Classes cannot be all public members.
c. In the C++ STL library, the map is a sequence container.
d. In the STL library there is a join method.
Problem 2. Multiple Choice
a. Which is NOT one of the STL iterator types?
a) input b) output c) backward d) bidirectional
b. For which STL container type is the random access iterator available?
a) map b) set c) vector d) any associative container
c) When opening a file for reading make sure :
a) it has at least 5 characters b) an ascii table is in the file
c) it exists in the specified directory d) it has an EOF e) it is
encrypted
Problem 3. True or false :which initializations are legal?
a. long mmm = 013;
b. double f = -412;
c. int flag = reinterpret_cast(true);
d. short d = 0x12345678;
e. boolean s = 10;
Problem 4. What gets printed?
#include
using namespace std;
class language {
public:
virtual void say_hello(void) = 0;
};
class japanese : public language {
public:
void say_hello(void) {
cout
-
public:
void say_hello(void) {
cout say_hello();
english eng_lan = *dynamic_cast(l);
eng_lan.say_hello();
return 0;
}
Problem 5. What gets printed? (Yan Li)
#include
#include
using namespace std;
int main()
{
int sum = 0, in_var;
fstream in;
in.open ("test_file", ios::in);
if (in.fail ())
{
cerr in_var;
sum += in_var;
cout
-
Problem 6. For the following leaf nodes as shown. Draw the Min-Max
tree. Assume it is a complete binary tree.
(4 3) (6 2) (2 1) (9 5) (3 1) (5 4) ( 7 5) (9 0)
For this tree evaluated with alpha-beta; what nodes need not be
evaluated?
Can you reorder the leaf nodes to get more alpha-beta cut-offs?
Problem 7. What gets printed?
/Ira Pohl Test question
#include
#include
#include
using namespace std;
class myexception: public exception
{
virtual const char* what() const throw()
{
return "My exception happened";
}
} myex;
int main () {
try
{
char data[100] = "Dr. Who" ;
cout