1.
A 'for' loop makes its test:
2.
According to the way "MyFunct" is being used below, what is its prototype?
int x,y;
//
//Program logic to fill x and y with data here
//
MyFunct(x, y);
Are you paying attention Back Row?!?
3.
What conditions must be present for the fragment below to
print the message "B is too small?"
if (a<20)
printf("Too Small.");
else
if (b >= 10)
printf("Everything is OK.");
else
printf("B is too small.");
a) (a < 20)
b) (a > 20) and (b >= 10)
c) (a>=20) and (b < 10)
d) None of the above
4.
What type of data must be in variable A below?
printf("A = %d now.\n", a );
a) int
b) char
c) float
d) double
5.
How are comments marked in C++?
a) With the ';' character
b) With either '//' (start of line) or '/* .. */'
c) With the '++' sequence
d) None of the above
6.
Which of these lists the fundamental data types of the C language in
correct order of precision?
a) INT - CHAR - FLOAT - LONG INT - DOUBLE
b) INT - CHAR - DOUBLE - LONG INT - FLOAT
c) FLOAT - CHAR - INT - LONG INT - DOUBLE
d) CHAR - INT - LONG INT - FLOAT - DOUBLE
e) None of the above
7.
What character code is used to end all strings in C?
a) '\n'
b) '\0'
c) '\7'
d) None of these
8.
What is the data type of the following expression?
"The quick brown fox jumped over the lazy dog."
a) int*
b) double*
c) float*
d) char*
e) None of the above
9.
Which of these would be BEST to do before using a pointer to access memory?
a) Make sure sufficient memory exists to use the pointer.
b) Check to see if your C compiler supports pointers.
c) Make sure the pointer address is valid
d) None of these
10.
What is special about the NULL pointer value?
a) The NULL pointer automatically dereferences the target object.
b) Arrays can only be accessed if a NULL pointer is used.
c) The NULL pointer is obtained when a disk I/O error occurs.
d) None of these
11.
What value is returned by the NEW operator when a memory allocation request fails?
a) -1
b) NULL pointer
c) 0xffff
d) None of the above
12.
Which statement below would correctly allocate an array of 500 integers by using
the 'NEW' operator?
a) int* Array = new int[500];
b) new int Array[500];
c) Array[500] = new int;
d) None of the above
13.
If the character sequence CR-LF ('\r' '\n') is encountered while reading a text file,
what character sequence will result on the C side of the interface?
a) '\r'
b) '\r' '\n'
c) '\0' (NUL)
d) None of the above
14.
Which standard stream below could be used to talk to the video display?
a) stdprn
b) stderr
c) stdout
d) stdaux
e) None of the above
15.
What must be done with any objects created through the 'NEW' operator prior to
termination of a program?
a) The objects must be tested to see if they hold proper values
b) The objects must be tested with the 'OLD' operator
c) The objects must be deleted from memory
d) None of the above
16.
What happens when an object is instantiated ?
a) The object is deleted or removed from memory
b) A pointer to the object is created
c) The object is dereferenced
d) None of these
17.
Which standard stream below could be used to talk to a printer?
a) stdout
b) stdprn
c) stderr
d) stdaux
e) None of the above
18.
What is the default access type for members of a class?
a) Public
b) Private
c) Protected
d) None of the above
19.
How does C++ discriminate between overloaded functions -- in other words, how does C++ know which version
of an overloaded function to call?
a) By looking at the returned data type and comparing it with how the caller is using the function
b) By examining the parameter list and comparing it with the caller's parameters
c) By counting the number of times the function has been called
d) None of the above
20.
The method of a class that is called automatically when objects of that class
are instantiated is called the:
a) Constructor
b) Initializer
c) Destructor
d) None of the above
21.
If a class member is defined as "private," who can access it?
a) Only functions within the same program
b) Any function within any process running on the computer
c) Only methods within the class itself
d) None of the above
22.
Suppose that the following overloaded function prototypes are given:
A) void Homer(int, char, float);
B) int Homer(double);
C) float Homer(double, int, int, double);
Which version will be called by the program statement:
Homer(35,'A', 3.14159);
a) Version "A"
b) Version "B"
c) Version "C"
d) Insufficient information
23.
Supposed that an array of CDonut objects called "OurDonuts" has been instantiated dynamically. What is the correct method for
deleting the array from memory?
a) delete OurDonuts;
b) delete []OurDonuts;
c) delete AllDonuts;
d) None of the above
24.
Suppose that a function has the following prototype:
void DonutLove(int& nLamars );
How will the calling function be passing its value?
a) By reference (implied pointer)
b) By pointer (explicit pointer operation required)
c) By value
d) None of the above
25.
What is the primary difference between objects defined with Class versus
those defined with Struct?
a) The Class objects have active behaviors
b) The Struct objects have built-in data protection
c) There's no functional difference between them
d) None of the above
26.
Given the class definition:
Class CGeek
{
public:
int m_nNeckties;
void TalkGibberish();
}
What is the correct prototype for the default constructor?
a) int Geek(char*);
b) void ~CGeek();
c) CGeek();
d) None of these
27.
Suppose that the following memory allocation is performed:
Class CDonuts MyDonuts[100];
Which statement will execute the method TasteTest() in the sixth element of
the array of objects?
a) TasteTest.MyDonuts[5];
b) MyDonuts[5].TasteTest();
c) CDonuts.TasteTest.MyDonuts(5);
d) None of the above
28.
The functions that are part of Class objects are called the:
a) Data members
b) Elements
c) Methods
d) None of the above
29.
What parameter passing method of C++ gives the advantage of passing values by
pointer, yet avoids the use of pointer notation in both the calling and called functions?
a) Passing by value
b) Passing by reference
c) Passing by array
d) None of these
OK, just one more question...are you ready?
30.
Which statement will correctly and dynamically allocate room for 13 (baker's dozen) CDonut objects?
a) CDonuts* NoSprinkles = new CDonuts[13];
b) CDonuts NoSprinkles[13];
c) NoSprinkles[13]->CDonuts[13];
d) None of the above
Extra information for Exam 1:
You will be asked to write two short programs. In one program, you will instantiate an array of
objects of a predefined type, and call one or more methods of each object. In the second program, you
will write the code to overload two of the built-in operators for objects of a class. Make sure
you know and understand the "formulas" for overloading operators!
Grade Exam!