Question: Computer Programing C++ Question 1 What is the address operator, which gives you the hexadecimal memory address of a variable (physical location in memory)? Exclamation
Computer Programing C++
Question 1
What is the address operator, which gives you the hexadecimal memory address of a variable (physical location in memory)?
|
| Exclamation point ( ! ) |
|
| Asterisk ( * ) |
|
| Ampersand ( & ) |
|
| Percent sign ( % ) |
Question 2
The statement string *ptrName = &name; has the same meaning as _____.
|
| string * ptrName = &name; |
|
| string ptrName* = &name; |
|
| *string ptrName = &name; |
|
| string ptrName = *name; |
Question 3
What does the following statement do? double *num2;
|
| It declares a double variable named num2. |
|
| It declares and initializes a pointer variable named num2. |
|
| It declares a pointer variable named num2. |
|
| It initializes a variable named *num2. |
Question 4
The delete operator cleans the memory that is located on the _____.
|
| stack |
|
| heap |
|
| binary triage |
|
| ternary operator |
Question 5
Which of the following statements is not valid C++ code?
|
| int* ptr = &num1; |
|
| int ptr = *num1; |
|
| float num1 = &ptr2; |
|
| float* num1 = &ptr2; |
Question 6
Which of the following statements deletes memory that has been dynamically allocated for an array?
|
| delete[] array; |
|
| delete new array; |
|
| delete dynamic array; |
|
| delete array; |
Question 7
If you have a pointer with a memory address, how do you get the content at that pointer location in memory?
|
| &ptrName |
|
| ptrName& |
|
| *ptrName |
|
| %ptrName |
Question 8
What does a pointer variable contain?
|
| Any legal C++ data type (e.g., int) |
|
| A decimal memory address |
|
| A binary memory address |
|
| A hexadecimal memory address |
Question 9
This data type can be used to create files, read data from them, and write data to them.
|
| ofstream |
|
| fstream |
|
| ifstream |
|
| stream |
Question 10
To access files from a C++ program, you must use this directive.
|
| #include |
|
| #include |
|
| #include |
|
| #include |
Question 11
This data type can be used to create files and read information from them into memory.
|
| ofstream |
|
| istream |
|
| ifstream |
|
| instream |
Question 12
When a file is opened, the file stream object's read position is _____.
|
| at the end of the file |
|
| at the beginning of the file |
|
| where the programmer positions it |
|
| at the location where it existed when the file was last closed |
Question 13
Objects are created from data types that encapsulate _____ and _____ together.
|
| numbers; text |
|
| data; functions |
|
| addresses; pointers |
|
| integers; floats |
Question 14
The _____ is used to protect important data.
|
| public access specifier |
|
| private access specifier |
|
| protect()member function |
|
| data protection operator, @, |
Question 15
The implementation code for the class methods are usually stored _____.
|
| on separate disk volumes |
|
| in their own header files |
|
| in .cpp files, separate from the class declarations or prototypes |
|
| under pseudonyms |
Question 16
A _____ is a member function that is automatically called when a class object is _____.
|
| destructor; created |
|
| constructor; created |
|
| static function; deallocated |
|
| utility function; declared |
Question 17
When a constructor accepts no arguments, it is called a(n) _____.
|
| parameterized constructor |
|
| default constructor |
|
| stand-alone constructor |
|
| arbitrator constructor |
Question 18
You can declare access specifiers for sections of your class, including private, protected, and public. If you do not declare an access specification, what is the default for a class?
|
| private |
|
| protected |
|
| public |
|
| The application crashes because you must add an access specifier. |
Question 19
To overload the - operator, you would write a function named _____.
|
| overload - |
|
| operator - |
|
| function - |
|
| operator.overload(-) |
Question 20
What is the prototype to overload the operator so this line works? Rectangle bigBox = smallBox1 + smallBox2;
|
| Rectangle operator+( const Rectangle & secondOne ) const; |
|
| Rectangle operator+( int ); |
|
| Rectangle operator++( const Rectangle & secondOne ) const; |
|
| Rectangle operator++( int ); |
Question 21
_____ allows us to create new classes based on existing classes.
|
| Polymorphism |
|
| Inheritance |
|
| Function overloading |
|
| Composition |
Question 22
A _____ of a base class expects to be overridden in a derived class.
|
| constructor function |
|
| destructor function |
|
| static function |
|
| virtual function |
Question 23
When member functions behave differently, depending upon which object performed the call, this is an example of _____.
|
| chaos theory |
|
| virtual insubordination |
|
| polymorphism |
|
| encapsulation |
Question 24
Abstract class references can be used in polymorphism if _____.
|
| all objects created in the abstract references are child (derived) objects |
|
| all objects created in the abstract references use the new keyword |
|
| all objects created in the abstract references are created on the memory stack |
|
| It is not possible to use abstract class references in polymorphism. |
Question 25
These are used to signal errors or unexpected events that occur while a program is running.
|
| Virtual functions |
|
| Destructors |
|
| Exceptions |
|
| Templates |
Question 26
In a function template, the programmer substitutes _____ for _____.
|
| parameters; data types |
|
| parameters; arguments |
|
| arguments; parameters |
|
| angle brackets; parentheses |
Question 27
Class templates allow you to create one general version of a class without having to _____.
|
| write any code |
|
| use member functions |
|
| use private members |
|
| duplicate code to handle multiple data types |
Question 28
The try block is immediately followed by one or more _____.
|
| errors |
|
| error messages |
|
| catch blocks |
|
| throw blocks |
Question 29
In the following statement, class Car : public Vehicle _____ is the derived (child) class.
|
| class |
|
| Car |
|
| public |
|
| Vehicle |
Question 30
_____ is commonly used to extend a class or to give it additional capabilities.
|
| Privacy |
|
| Inheritance |
|
| The constructor |
|
| The destructor |
Question 31
Write an Employee class that has data members for hourly pay rate and number of hours worked. The default constructor should set the hours worked and pay rate to zero. The class must have an accessor method for both the hours worked and rate of pay. The class must have mutator method for both the hours worked and rate of pay. Finally, the class should have a calculatePay method that returns the weekly pay based on the hours worked times the hourly pay rate.
Question 32
Demonstrate inheritance. Create an Airplane class with the following attributes: manufacturer : string speed : float Create a FigherPlane class that inherits from the Airplane class and adds the following attributes: numberOfMissiles : short
Question 33
Demonstrate a try-catch block for error handling. In the main method, get the number of kids for the person. If the person enters text (e.g., three), catch the exception, and tell the person about the error. Remember to reset the console input stream!
Question 34
Demonstrate composition. Create a HardDrive class with the following attributes. brand : string sizeInTB : float Create a Computer class with the following attributes. brand : string drive : HardDrive
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
