Cpp Quiz interview questions
118 questions. Tap “Show answer” to check yourself.
-
Keyword typed is used to declare
- A synonym for an existing type
- Absence of a type
- Objects that can be modified outside of a program control
- A member function that is defined in a subclass
Show answer
A. A synonym for an existing type
-
In C++ programming language, to write data that contains variables of type flat to an object of type of stream, which of the following should be used?
- Put ( )
- Seekg ( )
- Write ( )
- Insertion operator
Show answer
C. Write ( )
-
Classes are useful because they
- Can closely model objects in the real world
- Bring together all aspects of an entity in one place
- Permit data to be hidden from other classes
- Are removed from memory when not in use
Show answer
C. Permit data to be hidden from other classes
-
A function argument is a
- Value sent to function by the calling program
- Value returned by the function to the calling program
- Variable in the function that receives a value from the calling program
- Way that functions resist accepting the calling program’s values
Show answer
A. Value sent to function by the calling program
-
The break statement causes an exit
- From the innermost loop or switch
- Only from the innermost switch
- Only from the innermost loop
- From all loops and switches
Show answer
D. From all loops and switches
-
Element double array [7] is which element of the array?
- Sixth
- Seventh
- Eighth
- Impossible
Show answer
C. Eighth
-
In C++, a structure brings together a group of
- Items of the same data type
- Integers with user-defined names
- Related data items, variables
- All of these
Show answer
C. Related data items, variables
-
In C++, which of the following can legitimately be passed to a function?
- A constant
- A variable
- A structure
- All of these
Show answer
D. All of these
-
The public files in a class library usually contain
- Variable definition
- Class declarations
- Constant definitions
- Member function definitions
Show answer
B. Class declarations
-
The member function can always access the data in
- Any object of the class of which it is a member
- The public part of its class
- The class of which it is member
- The object of which is a member
Show answer
D. The object of which is a member
-
In a stock, the data item placed on the stack first is
- Given as index zero
- Not given as index number
- The first data item to be removed
- The last data item to be removed
Show answer
D. The last data item to be removed
-
Breaking a program into several files is desirable because
- A program can be divided functionally
- Each programmer can work on a separate file
- Some files don’t need to be recompiled each time
- Files can be marketed in object form
Show answer
A. A program can be divided functionally
- Advertisement
-
Turbo C++ library function can be used
- Draw lines and circles
- Write text in a variety of fonts and sizes
- Color any closed figure
- All of these
Show answer
D. All of these
-
Which of the following are good reasons to use an object oriented language?
- An object oriented program can be taught to correct its own errors
- Program statements are simpler than in procedural language
- We can define our own data types
- None of these
Show answer
C. We can define our own data types
-
In a class specified, data or functions and designated private are accessible
- Only to public members of class
- Only if you know the password
- To any function in the program
- To member functions of that class
Show answer
D. To member functions of that class
-
When a language has the capability to produce new data types, it is called
- Extensible
- Encapsulated
- Reprehensible
- None of these
Show answer
D. None of these
-
The dot operator connects which of the following two entities?
- Class object and member of that class
- Class and member of that class
- Class object and a class
- Class member and class object
Show answer
A. Class object and member of that class
-
A static function
- Should be called when an object is destroyed
- Can be called using the class name and function
- Is closely connected with an individual object of a class
- Is used when a dummy object must be created
Show answer
B. Can be called using the class name and function
-
The function bad( ) is declared in the header file
- <iostream.h>
- <stdio.h>
- <math.h>
- <stdlib.h>
Show answer
C. <math.h>
-
In C++, a function contained within a class is called
- A method
- A class function
- Member function
- None of these
Show answer
C. Member function
-
A base class
- behave badly when chips are down
- will be a generalized version of its derived classes
- correspond to something in the real world
- offer model more specific objects than its derived classes
Show answer
B. will be a generalized version of its derived classes
-
Copy constructor is invoked when a/an
- Argument is passed by value
- Argument is passed by reference
- Function returns for reference
- Function returns by value
Show answer
D. Function returns by value
-
A project file
- contains instructions for compiling and linking
- contains definitions for C++ variables
- examines contents of the files in the project
- examines contents of the files in the project
Show answer
A. contains instructions for compiling and linking
-
In C++, programs, the keyword friend appears in the
- class allowing access to another class
- private section of a class
- public section of a class
- all of these
Show answer
D. all of these
- Advertisement
-
A C++ stream is
- Associated with a particular class
- Flow of control through a function
- A file
- A flow of data from one place to another
Show answer
D. A flow of data from one place to another
-
The keyword volatile is used to declare
- Objects that can be modified outside of a program control
- Absence of a type
- A member function that is defined in a subclass
- All of these
Show answer
A. Objects that can be modified outside of a program control
-
In C language, the break statement causes an exit
- Only from the innermost switch
- Only from the innermost loop
- From all loops and switches
- From the innermost loop or switch
Show answer
D. From the innermost loop or switch
-
In a for loop with a multi-statement, loop body semicolons should appear
- The test expression
- Each statement within the loop body
- The closing brace in a multi-statement loop body
- Both (a) and (b)
Show answer
D. Both (a) and (b)
-
In C++, when an argument is passed by reference
- A variable is created in the function to hold the argument’s value
- A temporary variable is created in the calling program to hold the argument’s value
- The function cannot access the argument’s value
- The function accesses the argument’s original value in the calling program
Show answer
A. A variable is created in the function to hold the argument’s value
-
In new operator
- Each link contains data or a pointer to data
- Each link contains a pointer to the next link
- Links are stored in an array
- An array of pointers point to the links
Show answer
B. Each link contains a pointer to the next link