Accounting
Anthropology
Archaeology
Art History
Banking
Biology & Life Science
Business
Business Communication
Business Development
Business Ethics
Business Law
Chemistry
Communication
Computer Science
Counseling
Criminal Law
Curriculum & Instruction
Design
Earth Science
Economic
Education
Engineering
Finance
History & Theory
Humanities
Human Resource
International Business
Investments & Securities
Journalism
Law
Management
Marketing
Medicine
Medicine & Health Science
Nursing
Philosophy
Physic
Psychology
Real Estate
Science
Social Science
Sociology
Special Education
Speech
Visual Arts
Computer Science
Q:
Q1: The purpose of stack unwinding is to:a. Attempt to catch exceptions that are not caught in their scope.b. Improve catchblocks by allowing them to handle multiple exceptions.c. Return control to the function that created the exception.d. Aid the terminate command in shutting down the program.
Q:
Q2: Select the false statement. A rethrown exception:
a. Is detected by the next enclosing try block.
b. Is the immediate result of a throwcommand.
c. Can be processed by exception handlers following the enclosing try block.
d. Must have been fully processed at the time it was rethrown.
Q:
Q1: To rethrow an exception, the exception handler must:
a. Use the throw; statement.
b. Use the throw command with the same parameters as the original exception.
c. Return a reference to whatever caused the original exception.
d. Not have attempted to process that exception at all.
Q:
Q5: An exception:
a. Terminates program execution.
b. Terminates the block where the exception occurred.
c. Will terminate the block where the exception occurred unless a catch command stops it.
d. Will not terminate a block unless explicitly instructed to do so.
Q:
Q4: catch blocks are not required to contain:
a. Braces { }.
b. Parentheses ( ).
c. Some form of parameter type indication.
d. A parameter name.
Q:
Q3: The try block cannot:
a. Enclose the code that may throw the exception.
b. Enclose its own catch blocks.
c. Test enclosing try blocks for additional catch statements if this try block's catch statements can"t match the exception being thrown.
d. Have exceptions explicitly or implicitly thrown in the try block itself.
Q:
Q2: Once an exception is thrown, when can control return to the throw point?
a. Never.
b. Only after the exception is caught.
c. Once the stack unwinding process is completed.
d. Immediately after the exception is thrown.
Q:
Q1: The correct order in which an exception is detected and handled is:
a. try, catch, throw
b. throw, catch, try
c. catch, throw, try
d. try, throw, catch
Q:
Q1: Exception handling may allow a program to:
a. Terminate in a controlled manner.
b. Be more robust and fault-tolerant.
c. Continue executing as if no problem was encountered.
d. All of the above.
Q:
Q2: Untying an input stream, inputStream, from an output stream, outputStream, is done with the function call:
a. inputStream.untie().
b. inputStream.untie( &outputStream ).
c. inputStream.tie().
d. inputStream.tie( 0 ).
Q:
Q1: Select the false statement. Outputs are:
a. Flushed automatically at the end of a program.
b. Flushed when the buffer fills.
c. Able to be synchronized with inputs.
d. Never automatically tied to inputs.
Q:
Q2: The difference between the operator! member function and the operator void* member function is that:
a. They always return opposite boolean values.
b. They occasionally return opposite boolean values.
c. Of the two member functions, only operator! checks if eof has been set.
d. Of the two member functions, only operator void* checks if eof has been set.
Q:
Q1: The good member function will return false if:
a. The eof member function would return true.
b. The bad member function would return true.
c. The failbit member function would return true.
d. Any of the above.
Q:
Q1: To reset the format state of the output stream:a. Call the reset member function.b. Call the flags member function with the ios_base::fmtflags constant as the argument.c. Save a copy of the fmtflags value returned by calling member function flags before making any format changes, and then call flags again with that fmtflags value as the argument.d. You must manually apply each individual format change member function or stream manipulator to restore the default format state.
Q:
Q1: Which of the following is not true about bool values and how they're output with the output stream?
a. The old style of representing true/false values used -1 to indicate false and 1 to indicate true.
b. A bool value outputs as 0 or 1 by default.
c. Stream manipulator boolalpha sets the output stream to display bool values as the strings "true" and "false".
d. Both boolalpha and noboolalpha are "sticky" settings.
Q:
Q1: Which of the following outputs does not guarantee that the uppercase flag has been set?
a. All hexadecimal numbers appear in the form 0X87.
b. All numbers written in scientific notation appear the form 6.45E+010.
c. All text outputs appear in the form SAMPLE OUTPUT.
d. All hexadecimal numbers appear in the form AF6.
Q:
234500e-003
Q:
Q1: What will be output by the following statements?double x = .0012345;cout << fixed << x << endl;cout << scientific << x << endl;a. 1.234500e-0030.001235b. 1.23450e-0030.00123450c. .0012351.234500e-003d. 0.001234501.23450e-003
Q:
Q1: When the showbase flag is set:
a. The base of a number precedes it in brackets.
b. Decimal numbers are not output any differently.
c. "oct" or "hex" will be displayed in the output stream.
d. Octal numbers can appear in one of two ways.
Q:
Q1: Which of the following statements restores the default fill character?
a. cout.defaultFill();
b. cout.fill();
c. cout.fill( 0 );
d. cout.fill( ' ' );
Q:
Q1: Which of the following stream manipulators causes an outputted number's sign to be left justified, its magnitude to be right justified and the center space to be filled with fill characters?
a. left
b. right
c. internal
d. showpos
Q:
Q1: What will be output by the following statement?
cout << showpoint << setprecision(4) << 11.0 << endl;
a. 11
b. 11.0
c. 11.00
d. 11.000
Q:
Q1: Which of the following is a valid user-defined output stream manipulator header?
a. ostream& tab( ostream& output )
b. ostream tab( ostream output )
c. istream& tab( istream output )
d. void tab( ostream& output )
Q:
Q1: Which of the following is not true about setw and width?
a. If the width set is not sufficient the output prints as wide as it needs.
b. They are used to set the field width of output.
c. Both of them can perform two tasks, setting the field width and returning the current field width.
d. They only apply for the next insertion/extraction.
Q:
Q1: What will be output by the following statements?
double x = 1.23456789;
cout << fixed;
cout << setprecision(5) << x << endl;
cout.precision(3);
cout << x << endl;
cout << x << endl;
a. 1.2346
1.23
1.23
b. 1.23457
1.235
1.23456789
c. 1.2346
1.23
1.23456789
d. 1.23457
1.235
1.235
Q:
Q1: Which of the following is not a difference between hex and setbase?a. setbase is a parameterized stream manipulator and hex is not.b. setbase is provided by a different header file than hex.c. setbase(16) and hex have different effects on stream output.d. setbase takes an argument but hex does not.
Q:
Q1: Which of the following is a difference between the read and write functions?a. One performs formatted I/O and the other does not.b. They take different types of parameters.c. write and gcount are member functions of the same class, whereas read is not.d. The failbit is set only with read.
Q:
Q1: If unexpected data is processed in an I/O operation:
a. An exception will be thrown.
b. An error message will automatically be displayed.
c. The program will terminate execution.
d. Various error bits will be set.
Q:
Q2: Upon encountering the designated delimiter character, the ignore member function will:
a. Read it in and return its value.
b. Ignore it and continue reading and discarding characters.
c. Terminate.
d. Replace it with an EOF character.
Q:
Q1: The putback member function returns to the input stream the previous character obtained by:a. A get from the input stream.b. Using the stream extraction operator on the input stream.c. Reading input from the keyboard.d. Reading a file from disk.
Q:
Q1: One difference between the three-argument version of the get function and the getline function is that:a. Only get has a delimiter.b. The getline function removes the delimiter from the stream.c. Only get adds the delimiter to the array.d. getline stores the characters it reads into its character array argument.
Q:
Q1: The stream-extraction operator:a. Does not normally accept white-space characters.b. Returns true when the end-of-file is encountered.c. Sets the stream's failbit if the operation fails.d. Sets the stream's badbit if the data is of the wrong type.
Q:
Q1: Which of the following is an illegal use of function put?
a. cout.put( 'A' );
b. cout.put( "A" );
c. cout.put( 'A' ).put( '
' );
d. cout.put( 65 );
Q:
Q1: Which of the following prints the address of character string string given the following declaration?
char * string = "test";
a. cout << string;
b. cout << *&string;
c. cout << static_cast< void * >( string );
d. cout << * string;
Q:
Q1: Which of the following is not a member function of the C++ ostream class?
a. Stream-insertion operator (<<).
b. Stream-extraction operator (>>).
c. put.
d. write.
Q:
.3 Q3: Which of the following classes is deepest in the inheritance hierarchy?
a. basic_iostream
b. basic_ofstream
c. basic_ifstream
d. basic_fstream
Q:
Q2: Which of the following is not an object of the ostream class?
a. cout
b. cerr
c. cin
d. clog
Q:
Q1: Which of the following classes is a base class of the other three?
a. basic_ios
b. basic_istream
c. basic_ostream
d. basic_iostream
Q:
Q2 [C++11] Which of the following statements is false?
a. The C++ standard redesigned the classic C++ stream classes, which processed only chars, as class templates with specializations for processing characters of types char and wchar_t, respectively.
b. C++11 added type char64_t to handle the new double-width Unicode characters.
c. The size of type wchar_t is not specified by the C++ standard.
d. C++11's new char16_t and char32_t types for representing Unicode characters were added to provide character types with explicitly specified sizes.
Q:
Q1: Which C++ data type was designed to store Unicode characters?
a. char
b. long
c. wchar_t
d. size_t
Q:
Q2: __________ is usually faster than __________.
a. High-level I/O, low-level I/O.
b. Low-level I/O, high-level I/O.
c. Low-level I/O, internal data processing.
d. High-level I/O, internal data processing.
Q:
Q1: Select the correct statement regarding C++ I/O streams:
a. C++ provides only high-level I/O capabilities because it is a high-level programming language.
b. High-level (formatted) I/O is best for large-volume transfers.
c. Low-level I/O breaks information down into small, meaningful groups of related bytes.
d. Programmers generally prefer high-level I/O to low-level I/O.
Q:
Q1: Which of the following statements is not true about C++ input/output (I/O) features?
a. C++ allows users to specify I/O for their own data types.
b. C++ automatically calls the correct I/O operations for standard types.
c. C++ has some object-oriented I/O features.
d. C++ borrowed its type safe I/O capabilities from C.
Q:
Q1: virtual destructors must be used when:a. The constructor in the base class is virtual.b. delete is used on a base-class pointer to a derived-class object.c. delete is used on a derived-class object.d. A constructor in either the base class or derived class is virtual.
Q:
Q4: dynamic_cast is often used to:
a. Perform type checking for objects.
b. Convert pointers to strings.
c. Upcast pointers.
d. Downcast pointers.
Q:
Q3: The __________ operator returns a reference to a __________ object:
a. typeid, type_info
b. typeinfo, type_id
c. typeid, data_type
d. typeinfo, type
Q:
Q2: Run-time type information can be used to determine:
a. A function's return type.
b. A function's argument type.
c. An object's type.
d. The number of arguments a function takes.
Q:
Q1: The line:
virtual double functionX() const = 0;
in a class definition indicates that the class is probably a:
a. Base class.
b. Derived class.
c. Protected class.
d. Library class.
Q:
Q4: Abstract classes do not necessarily have:
a. A 0 pointer in their vtable.
b. A virtual function prototype with the notation = 0.
c. Zero instances of their class.
d. Zero references to their class.
Q:
Q3: The C++ compiler makes objects take up more space in memory if they:
a. Are derived from base classes.
b. Have virtual functions.
c. Have only protected members.
d. Are referenced by pointers.
Q:
Q2: Concrete classes that inherit virtual functions but do not override their implementations:
a. Have vtables which are the same as those of their base classes.
b. Receive their own copies of the virtual functions.
c. Receive pointers to their base classes' virtual functions.
d. Receive pointers to pure virtual functions.
Q:
Q1: An abstract class will:
a. Have all zero function pointers in its vtable.
b. Have at least one zero function pointer in its vtable.
c. Share a vtable with a derived class.
d. Have fewer zero function pointers in its vtable than concrete classes have.
Q:
Q1: What mistake prevents the following class declaration from functioning properly as an abstract class?
class Shape
{
public:
virtual double print() const;
double area() const { return base * height; }
private:
double base;
double height;
};
a. There are no pure virtual functions.
b. There is a non-virtual function.
c. private variables are being accessed by a public function.
d. Nothing, it functions fine as an abstract class.
Q:
Q4: Which of the following is not allowed?
a. Objects of abstract classes.
b. Multiple pure virtual functions in a single abstract class.
c. References to abstract classes.
d. Arrays of pointers to abstract classes.
Q:
Q3: The main difference between a pure virtual function and a virtual function is:a. The return type.b. The member access specifier.c. That a pure virtual function cannot have an implementation.d. The location in the class.
Q:
Q2: Abstract classes:
a. Contain at most one pure virtual function.
b. Can have objects instantiated from them if the proper permissions are set.
c. Cannot have abstract derived classes.
d. Are defined, but the programmer never intends to instantiate any objects from them.
Q:
Q1: The line:
virtual double earnings() const = 0;
appears in a class definition. You cannot deduce that:
a. All classes that directly inherit from this class will override this method.
b. This class is an abstract class.
c. Any concrete class derived from this class will have an earnings function.
d. This class will probably be used as a base class for other classes.
Q:
Q1: Problems using switch logic to deal with many objects of different types do not include:
a. Forgetting to include an object in one of the cases.
b. Having to update the switch statement whenever a new type of object is added.
c. Having to track down every switch statement to do an update of object types.
d. Not being able to implement separate functions on different objects.
Q:
Q4[C++11]: Which of the following statements is true?a. In C++11, all classes can be used as base classes.b. In C++11, only classes that are not declared as final can be used as base classes.c. In C++11, only classes that are declared as base can be used as base classes.d. None of the above
Q:
Q3: Which of the following statements about virtual functions is false?a. They allow the program to select the correct implementation at execution time.b. They can use either static or dynamic binding, depending on the handles on which the functions are called.c. They do not remain virtual down the inheritance hierarchy.d. They can be called using the dot operator.
Q:
.4 Q2: virtual functions must:
a. Be overridden in every derived class.
b. Be declared virtualin every derived class.
c. Be declared virtual in the base class.
d. Have the same implementation in every derived class.
Q:
.4 Q1: If objects of all the classes derived from the same base class all need to draw themselves, the draw function would most likely be declared:
a. private
b. virtual
c. protected
d. friend
Q:
.3 Q1: Downcasting enables:
a. A derived-class object to be treated as a base-class object.
b. A base-class object to be treated as a derived-class object.
c. Making a base-class pointer into a derived-class pointer.
d. Making a derived-class pointer into a base -class pointer.
Q:
.2 Q1: Which of the following assignments would be a compilation error?
a. Assigning the address of a base-class object to a base-class pointer.
b. Assigning the address of a base-class object to a derived-class pointer.
c. Assigning the address of a derived-class object to a base-class pointer.
d. Assigning the address of a derived-class object to a derived-class pointer.
Q:
.1 Q1: Employee is a base class and HourlyWorker is a derived class, with a redefined non-virtual print function. Given the following statements, will the output of the two print function calls be identical?
HourlyWorker h;
Employee *ePtr = &h;
ePtr->print();
ePtr->Employee::print();
a. Yes.
b. Yes, if print is a static function.
c. No.
d. It would depend on the implementation of the print function.
Q:
Q1: Which of the following would not be a member function that derived classes Fish, Frog and Bird should inherit from base class Animal and then provide their own definitions for, so that the function call can be performed polymorphically?
a. eat
b. sleep
c. move
d. flapWings
Q:
Q1: Which of the following statements about polymorphism is false?
a. With polymorphism, you can direct a variety of objects to behave in manners appropriate to those objects without even knowing their types.
b. With polymorphism, new types of objects that can respond to existing messages can easily be incorporated into a system without modifying the base system.
c. Polymorphism enables you to deal in specifics and let the execution-time environment concern itself with the generalities.
d. To get polymorphic behavior among existing objects, those objects must be instantiated from classes in the same inheritance hierarchy.
Q:
Q1: Polymorphism is implemented via:
a. Member functions.
b. virtual functions and dynamic binding.
c. inline functions.
d. Non-virtual functions.
Q:
Q2: Which of the following is true about using inheritance in software engineering?
a. Common attributes and behaviors should be factored out of closely related classes and placed into a base class from which the original classes can now inherit.
b. It is best to create a huge class library to make it easy for a client to find the most appropriate class for his or her needs.
c. A class produced through inheritance should be as large as possible to fully encompass all of the functionality it should offer.
d. The standard C++ libraries that are shipped with C++ compilers are usually enough to accomplish anything an application might need to do.
Q:
Q1: Theoretically, clients do not need to see the _________ of classes from which they derive other classes.
a. Header files.
b. Source code.
c. Object code.
d. Interface.
Q:
Q2: When deriving a class from a protected base class, the public members of the base class become _________ and the protected members of the base class become __________?
a. protected, private
b. public, private
c. protected, protected
d. public, protected
Q:
Q1: Which forms of inheritance are is-a relationships?
a. All forms of inheritance are is-a relationships.
b. Only public and private.
c. Only public and protected.
d. Only public.
Q:
Q3[C++11]: Which of the following statements about inheriting base class constructors is false?
a. To inherit a base class's constructors, you write the following line of code in the derived class definition (BaseClass is the base class's name):
using BaseClass::BaseClass;
b. If an inherited base-class constructor has default arguments, the line of code in Part (a) causes the compiler to generate a derived-class constructor with the same default arguments.
c. By default, each inherited constructor has the same access level (public, protected or private) as its corresponding base-class constructor.
d. If the derived class does not explicitly define constructors, the compiler generates a default constructor in the derived classeven if it inherits other constructors from its base class.
Q:
Q2: Base class constructors and assignment operators:
a. Are not inherited by derived classes.
b. Should not be called by derived class constructors and assignment operators.
c. Can be inherited by derived classes, but generally are not.
d. Can call derived-class constructors and assignment operators.
Q:
Q1: When an object of a derived class is instantiated, the __________ constructor initializes the _________ members.
a. Base class, base class.
b. Derived class, base class.
c. Base class, derived class.
d. Derived class, public.
Q:
Q6: From most restrictive to least restrictive, the access modifiers are:a. protected, private, publicb. private, protected, publicc. private, public, protectedd. protected, public, private
Q:
Q5: When should base class members be declared protected?a. When all clients should be able to access these members.b. When these members are used only by member functions of this base class.c. When these members should be available only to derived classes (and friends), but not to other clients.d. The protected access specified should never be used.
Q:
Q4: protected base class members cannot be accessed by:a. Functions that are neither friends of the base class, derived-class member functions nor friends of a derived class.b. friends of the base class.c. Functions that are not derived-class member functions.d. friends of derived classes.
Q:
Q3: Which of the following is not one of the disadvantages of using the "copy-and-paste" approach to duplicating code from one class into another class?a. Errors are prone to be spread around.b. It is time consuming.c. It forces the system to store many physical copies of the code, creating a code-maintenance nightmare.d. All of the above are disadvantages of the "copy-and-paste" approach.
Q:
Q2: Assuming the following is the beginning of the constructor definition for class BasePlus-CommissionEmployee which inherits from class Point,BasePlusCommissionEmployee::BasePlusCommissionEmployee( string first,string last, string ssn, double sales, double rate, double salary ): CommissionEmployee( first, last, ssn, sales, rate )The second line:a. Invokes the CommissionEmployee constructor with arguments.b. Causes a compiler error.c. Is unnecessary because the CommissionEmployee constructor is called automatically.d. Indicates inheritance.