This is a mock Exam for the C++ programmers. It is created by Genesis InSoft Limited
(admin@genesisinsoft.com)
and may be freely distributed so long as it is unmodified. Please email us if you
have any corrections or comments.
The phenomenon where the object outlives the program execution time and exists between
executions of a program is known as.
- Global Object
- Persistent Object
- Genericity
- Delegation
Answer to Question 1
Object-Based Programming Language supports
- Inheritance
- Polymorphism
- Encapsulation
- All of the above
Answer to Question 2
Abstraction is crucial to understanding
- Class
- Application
- Object
- Control flow
Answer to Question 3
Object oriented design decomposes a system into
- Classes
- Objects
- Structures
- Methods
Answer to Question 4
If a class member function is declared a const, the function
- Does not change the value of any data member of that class
- Does not change the value of any data member of implied object
- Does not change the value of any data member of that class
- All of the above
Answer to Question 5
What is the output of the program?
#include <stdio.h>
float cal (float value)
{
return (3 * value);
}
void main()
{
int a = 10;
float b = cal ("123");
}
- 369
- 123
- Compilation error - Cannot convert from char to float
- None of the above
Answer to Question 6
The act of grouping into a single object, both data and the operation that affect
that data is known as
- Encapsulation
- Inheritance
- Abstraction
- None of the above
Answer to Question 7
What is a class?
- It is a region of storage.
- It defines a data type.
- It is exactly same as a struct in c.
- All of the above.
Answer to Question 8
What is the output of the program?
#include <iostream.h>
void main ()
{
for(int j = 1, sum = 0; j < 5; j++)
sum += j;
sum = j;
cout << sum;
}
- 5
- 10
- Compilation error. Undefined variable sum and j
- 6
Answer to Question 9
Which one supports unknown data types in a single framework?
- Inheritance
- Virtual functions
- Templates
- Abstract Base Class
Answer to Question 10
Inheritance is expressed by the following statement?
- class car : public vehicle
- class car extends vehicle
- public class car extends vehicle
- class car inherits vehicle
Answer to Question 11
Object oriented design decomposes a system into
- Classes
- Objects
- Structures
- Methods
Answer to Question 12
Which of the following statements is not correct?
- You can create new operators like $ or @
- You cannot change an operator's template
- Operators can only be overloaded when used with abstract data class
- Unary operators overloaded by means of a member functions takes no explicit arguments
and return no explicit values
Answer to Question 13
Which of the following is false about struct and class in C++?
- The members and base classes of a struct are public by default, while in class,
they are private by default
- Struct and class are otherwise functionally equivalent
- A class supports all the access specifiers like private, protected and public
- A struct cannot have protected access specifier
Answer to Question 14
Protected keyword is frequently used
- For function overloading
- For protecting data
- For inheritance
- For security purpose
Answer to Question 15
Abstract base class is one, which has
- All pure virtual functions
- At least one pure virtual function
- Functions with abstract keyword
- No pure virtual functions
Answer to Question 16
What is exception handling?
- Errors which occur at runtime
- When abnormal situation arises at compile time
- When errors occur at link time
- None of the above
Answer to Question 17
What is the output of the program?
#include <iostream.h>
inline int max(int x, int y)
{
return(x > y ? x : y);
}
void main()
{
int(* max_func)(int,int)=max;
cout << max_func(75,33);
}
- 75
- Error - Undefined symbol max_func
- 33
- None of the above
Answer to Question 18
Which keyword is used to decide on the choice of function or method at runtime?
- Abstract
- Virtual
- Protected
- Static
Answer to Question 19
Which of the following is a correct statement?
- Abstract class object can be created
- Pointer to abstract class can be created
- Reference to abstract class can be created
- Both B and C
Answer to Question 20
Answers
Answer 1 - B
Back to question 1
Answer 2 - C
Back to question 2
Answer 3 - C
Back to question 3
Answer 4 - B
Back to question 4
Answer 5 - B
Back to question 5
Answer 6 - C
Back to question 6
Answer 7 - A
Back to question 7
Answer 8 - B
Back to question 8
Answer 9 - A
Back to question 9
Answer 10 - C
Back to question 10
Answer 11 - A
Back to question 11
Answer 12 - B
Back to question 12
Answer 13 - A
Back to question 13
Answer 14 - D
Back to question 14
Answer 15 - C
Back to question 15
Answer 16 - B
Back to question 16
Answer 17 - A
Back to question 17
Answer 18 - A
Back to question 18
Answer 19 - B
Back to question 19
Answer 20 - D
Back to question 20