C ++
C ++
A.Virtual class
B. Abstract class
C. Singleton class
D.Friend class
Answer: Option C
Explanation:
Answer: Option B
Explanation:
Answer: Option B
Explanation:
Answer: Option B
Explanation:
5. Which of the following concepts means determining at runtime what method to invoke?
A.Data hiding
B. Dynamic Typing
C. Dynamic binding
D.Dynamic loading
Answer: Option C
6. Which of the following term is used for a function defined inside a class?
A.Member Variable
B. Member function
C. Class function
D.Classic function
Answer: Option B
Explanation:
7. Which of the following concept of oops allows compiler to insert arguments in a function call
if it is not specified?
A.Call by value
B. Call by reference
C. Default arguments
D.Call by pointer
Answer: Option C
Explanation:
Answer: Option D
Explanation:
Answer: Option C
Explanation:
10. Which of the following concepts of OOPS means exposing only necessary information to
client?
A.Encapsulation
B. Abstraction
C. Data hiding
D.Data binding
Answer: Option C
Answer: Option C
Explanation:
13. Which of the following concepts provides facility of using object of one class inside another
class?
A.Encapsulation
B. Abstraction
C. Composition
D.Inheritance
Answer: Option C
Explanation:
Answer: Option B
Explanation:
The two main types of polymorphism are run-time (implemented as inheritance and virtual
functions), and compile-time (implemented as templates).
View Answer Discuss in Forum Workspace Report
16. Which of the following concepts means adding new components to a program as it runs?
A.Data hiding
B. Dynamic typing
C. Dynamic binding
D.Dynamic loading
Answer: Option D
Explanation:
Answer: Option A
Explanation:
Answer: Option C
Explanation:
Answer: Option B
Explanation:
Answer: Option D
Answer: Option D
Explanation:
22. Which of the following concepts means wrapping up of data and functions together?
A.Abstraction
B. Encapsulation
C. Inheritance
D.Polymorphism
Answer: Option B
Explanation:
23. Which of the following concepts means waiting until runtime to determine which function to
call?
A.Data hiding
B. Dynamic casting
C. Dynamic binding
D.Dynamic loading
Answer: Option C
Explanation:
Answer: Option B
Explanation:
Answer: Option B
26. Which of the following is the correct class of the object cout?
A.iostream
B. istream
C. ostream
D.ifstream
Answer: Option C
Explanation:
27. Which of the following cannot be used with the keyword virtual?
A.class
B. member functions
C. constructor
D.destructor
Answer: Option C
Explanation:
Answer: Option D
Explanation:
Answer: Option D
Explanation:
Answer: Option B
31. Which of the following is the correct way of declaring a function as constant?
A.const int ShowData(void) { /* statements */ }
B. int const ShowData(void) { /* statements */ }
C. int ShowData(void) const { /* statements */ }
D.Both A and B
Answer: Option C
Explanation:
Answer: Option A
Explanation:
Explanation:
34. Which of the following factors supports the statement that reusability is a desirable feature of
a language?
A.It decreases the testing time.
B. It lowers the maintenance cost.
C. It reduces the compilation time.
D.Both A and B.
Answer: Option D
Explanation:
35. Which of the following ways are legal to access a class data member using this pointer?
A.this->x
B. this.x
C. *this.x
D.*this-x
Answer: Option A
Answer: Option D
Explanation:
A.Only I is true.
B. Both I and II are false.
C. Only II is true.
D.Both I and II are true.
Answer: Option B
Explanation:
38. What happens if the base and derived class contains definition of a function with same
prototype?
A.Compiler reports an error on compilation.
B. Only base class function will get called irrespective of object.
C. Only derived class function will get called irrespective of object.
Base class object will call base class function and derived class object will call derived
D.
class function.
Answer: Option D
Explanation:
39. Which of the following are available only in the class hierarchy chain?
A.Public data members
B. Private data members
C. Protected data members
D.Member functions
Answer: Option C
Explanation:
Answer: Option C
Answer: Option C
Explanation:
42. In which of the following a virtual call is resolved at the time of compilation?
A.From inside the destructor.
B. From inside the constructor.
C. From inside the main().
D.Both A and B.
Answer: Option D
Explanation:
Explanation:
44. Which one of the following is the correct way to declare a pure virtual function?
A.virtual void Display(void){0};
B. virtual void Display = 0;
C. virtual void Display(void) = 0;
D.void Display(void) = 0;
Answer: Option C
Explanation:
45. Which of the following header file includes definition of cin and cout?
A.istream.h
B. ostream.h
C. iomanip.h
D.iostream.h
Answer: Option D
Answer: Option B
Explanation:
Answer: Option D
Explanation:
Answer: Option B
Explanation:
49. Which one of the following is correct about the statements given below?
A.Only II is correct.
B. Both I and II are correct.
C. Only I is correct.
D.Both I and II are incorrect.
Answer: Option C
Explanation:
Answer: Option D
Answer: Option D
Explanation:
Answer: Option B
Explanation:
Explanation:
54. Which of the following access specifier is used as a default in a class definition?
A.protected
B. public
C. private
D.friend
Answer: Option C
Explanation:
Answer: Option D
Answer: Option B
Explanation:
Answer: Option B
1) Which of the following is not used to seek a file pointer?
a. ios::cur
b. ios::set
c. ios::end
d. ios::beg
Answer Explanation
ANSWER: ios::set
Explanation:
No explanation is available for this question!
2) During dynamic memory allocation in CPP, new operator returns _________ value if
memory allocation is unsuccessful.
a. False
b. NULL
c. Zero
d. None of these
Answer Explanation
ANSWER: NULL
Explanation:
No explanation is available for this question!
a. True
b. False
Answer Explanation
ANSWER: False
Explanation:
No explanation is available for this question!
4) Which of the followings is/are pointer-to-member declarator?
a. ->*
b. .*
c. ::*
d. both a and b
Answer Explanation
ANSWER: ::*
Explanation:
No explanation is available for this question!
a. 0
b. 1
c. Garbage value
d. Compiler dependent
Answer Explanation
ANSWER: 0
Explanation:
No explanation is available for this question!
a. Iterators
b. Punctuators
c. Manipulators
d. Allocators
Answer Explanation
ANSWER: Manipulators
Explanation:
No explanation is available for this question!
a. Polymorphism
b. Encapsulation
c. Inheritance
d. Both a and c
Answer Explanation
ANSWER: Inheritance
Explanation:
No explanation is available for this question!
a. protected
b. private
c. public
d. static
Answer Explanation
ANSWER: private
Explanation:
No explanation is available for this question!
9) class TEST
{
private:
int roll_no;
public:
int age;
char name[20];
private:
int grade;
protected:
char gender[20];
private:
private:
int m1, m2, m3;
};
a. Yes
b. No
Answer Explanation
ANSWER: Yes
Explanation:
No explanation is available for this question!
10) Which of the following is CPP style type-casting?
a. per = total/(float)m
b. per = total/float(m)
c. per = (float)total/m
d. None of these
Answer Explanation
ANSWER: per = total/float(m)
Explanation:
No explanation is available for this question!
11) If a program uses Inline Function, then the function is expanded inline at
___________.
a. Compile time
b. Run time
c. Both a and b
d. None of these
Answer Explanation
ANSWER: Run time
Explanation:
No explanation is available for this question!
12) In CPP, the size of the character array should be one larger than the number of
characters in the string.
a. True
b. False
Answer Explanation
ANSWER: True
Explanation:
No explanation is available for this question!
13) Which of the following is/are valid ways to allocate memory for an integer by dynamic
memory allocation in CPP?
Explanation:
No explanation is available for this question!
14) Which of the following is the perfect set of operators that can’t be overloaded in CPP
?
a. +=, ?, :: , >>
b. >>, <<, ?, *, sizeof()
c. :: , . , .* , ?:
d. :: , ->, * , new, delete
Answer Explanation
ANSWER: :: , . , .* , ?:
Explanation:
No explanation is available for this question!
Explanation:
No explanation is available for this question!
16) To perform File I/O operations, we must use _____________ header file.
a. < ifstream>
b. < ofstream>
c. < fstream>
d. Any of these
Answer Explanation
ANSWER: < fstream>
Explanation:
No explanation is available for this question!
17) An exception is thrown using _____________ keyword in CPP.
a. throws
b. throw
c. threw
d. Thrown
Answer Explanation
ANSWER: throw
Explanation:
No explanation is available for this question!
1. flush
2. base
3. ends
4. oct
5. bin
6. skipws
a. Only 1, 6
b. Only 1,4,6
c. Only 1,3,6
d. Only 2,5
Answer Explanation
ANSWER: Only 2,5
Explanation:
No explanation is available for this question!
19) If default constructor is not defined, then how the objects of the class will be created?
Explanation:
No explanation is available for this question!
Answer Explanation
ANSWER: Yes
Explanation:
No explanation is available for this question!
21) Members of the class can be declared with auto, extern or register storage classes.
a. True
b. False
Answer Explanation
ANSWER: False
Explanation:
No explanation is available for this question!
22) C structure differs from CPP class in regards that by default all the members of the
structure are __________ in nature.
a. private
b. protected
c. public
d. None of these
Answer Explanation
ANSWER: public
Explanation:
No explanation is available for this question!
23) Which of the following best defines the syntax for template function ?
a. Template
b. Template return_type Function_Name(Parameters)
c. Both a and b
d. None of these
Answer Explanation
ANSWER: Both a and b
Explanation:
No explanation is available for this question!
a. auto
b. void
c. asm
d. None of these
Answer Explanation
ANSWER: void
Explanation:
No explanation is available for this question!
a. Only 1,2,4
b. 1,2,4,5
c. 1,3,5
d. 1,4,5
Answer Explanation
ANSWER: 1,4,5
Explanation:
No explanation is available for this question!
a. Only 2
b. Only 2,5
c. Only 2,3,4,5
d. Only 2 , 3 , 5
e. All of these
Answer Explanation
ANSWER: Only 2 , 3 , 5
Explanation:
No explanation is available for this question!
a. True
b. False
Answer Explanation
ANSWER: False
Explanation:
No explanation is available for this question!
3) By default, if a function with minimum lines of code is declared and defined inside the
class becomes Inline function.
a. True
b. False
Answer Explanation
ANSWER: True
Explanation:
No explanation is available for this question!
4) class X, class Y and class Z are derived from class BASE. This is ______ inheritance.
a. Multiple
b. Multilevel
c. Hierarchical
d. Single
Answer Explanation
ANSWER: Hierarchical
Explanation:
No explanation is available for this question!
a. Only 1, 5
b. Only 1, 6
c. Only 2, 6
d. Only 2, 4
Answer Explanation
ANSWER: Only 2, 4
Explanation:
No explanation is available for this question!
a. Yes
b. No
Answer Explanation
ANSWER: Yes
Explanation:
No explanation is available for this question!
7) Streams that will be performing both input and output operations must be declared as
class _________ .
a. iostream
b. fstream
c. stdstream
d. Stdiostream
Answer Explanation
ANSWER: fstream
Explanation:
No explanation is available for this question!
8) Exception handlers are declared with ____________ keyword.
a. Try
b. catch
c. throw
d. Finally
Answer Explanation
ANSWER: catch
Explanation:
No explanation is available for this question!
a. Only 1, 4, 5
b. Only 1, 2, 3
c. Only 1, 4
d. Only 1, 2
Answer Explanation
ANSWER: Only 1, 4
Explanation:
No explanation is available for this question!
a. instance variable
b. named constant
c. global variable
d. class variable
Answer Explanation
ANSWER: class variable
Explanation:
No explanation is available for this question!
11) Which of the following operator is used to release the dynamically allocated memory
in CPP?
a. remove
b. free
c. delete
d. both b and c
Answer Explanation
ANSWER: delete
Explanation:
No explanation is available for this question!
12) Which of the following is not a false statement about new operator?
a. It can’t be overloaded.
b. It returns garbage value when memory allocation fails.
c. It automatically computes the size of the data object.
d. All of these
Answer Explanation
ANSWER: It automatically computes the size of the data object.
Explanation:
No explanation is available for this question!
13) Private members of the class are accessible only to the members of the same class.
a. True
b. False
Answer Explanation
ANSWER: False
Explanation:
No explanation is available for this question!
Explanation:
No explanation is available for this question!
15) To create an output stream, we must declare the stream to be of class ___________ .
a. ofstream
b. ifstream
c. iostream
d. None of these
Answer Explanation
ANSWER: ofstream
Explanation:
No explanation is available for this question!
a. True
b. False
Answer Explanation
ANSWER: False
Explanation:
No explanation is available for this question!
a. Only 1,4,5
b. Only 2,3,5
c. Only 1,3,4
d. All of these
Answer Explanation
ANSWER: Only 1,3,4
Explanation:
No explanation is available for this question!
18) Which of the followings is/are not false about friend function ?
a. Only 2,4
b. Only 1,2,5
c. Only 2,3,5
d. All of these
Answer Explanation
ANSWER: Only 2,3,5
Explanation:
No explanation is available for this question!
int x = 786;
cout << setfill(‘*’) << setw(6) << x;
a. 786***
b. **786
c. ***786
d. ******
Answer Explanation
ANSWER: ***786
Explanation:
No explanation is available for this question!
a. void
b. long
c. char
d. Int
Answer Explanation
ANSWER: Int
Explanation:
No explanation is available for this question!
21) Default values for a function are need to be specified from left to right only.
a. True
b. False
Answer Explanation
ANSWER: False
Explanation:
No explanation is available for this question!
22) During a class inheritance in CPP, if the visibility mode or mode of derivation is not
provided, then by default visibility mode is ___________.
a. public
b. protected
c. private
d. Friend
Answer Explanation
ANSWER: private
Explanation:
No explanation is available for this question!
23) The derivation of Child class from Base class is indicated by ____ symbol.
a. ::
b. :
c. ;
d. |
Answer Explanation
ANSWER: :
Explanation:
No explanation is available for this question!
24) If we have object from fstream class, then what is the default mode of opening the file?
a. ios::in|ios::out
b. ios::in|ios::out|ios::trunc
c. ios::in|ios::trunc
d. Default mode depends on compiler
Answer Explanation
ANSWER: Default mode depends on compiler
Explanation:
No explanation is available for this question!
a. int
b. bool
c. float
d. char *
Answer Explanation
ANSWER: bool
1) Public data members and member functions of the class are accessible ONLY to the
member functions of that class.
a. True
b. False
Answer Explanation
ANSWER: False
Explanation:
No explanation is available for this question!
2) Only functions of the class can access the data of the class and they(functions) provides
the interface between data, objects and the program. This kind isolation of the data from
direct access by the program is called _______________ .
a. Data Abstraction
b. Data Hiding
c. Data Binding
d. Data Encapsulation
Answer Explanation
ANSWER: Data Hiding
Explanation:
No explanation is available for this question!
a. Custom
b. Dynamic
c. Static
d. Default
Answer Explanation
ANSWER: Default
Explanation:
No explanation is available for this question!
4) If we have object from ofstream class, then default mode of opening the file is _____ .
a. ios::in
b. ios::out
c. ios::in|ios::trunc
d. ios::out|ios::trunk
Answer Explanation
ANSWER: ios::out|ios::trunk
Explanation:
No explanation is available for this question!
a. virtual function
b. static function
c. friend function
d. const member function
Answer Explanation
ANSWER: virtual function
Explanation:
No explanation is available for this question!
Explanation:
No explanation is available for this question!
a. explicit
b. garbage
c. bool
d. static
Answer Explanation
ANSWER: bool
Explanation:
No explanation is available for this question!
8) We can initialize a value of static variable of a class only when its object is created. No
other initialization is permitted.
a. True
b. False
Answer Explanation
ANSWER: False
Explanation:
No explanation is available for this question!
a. protected members of the base class become private members of derived class
b. public members of the base class become private members of derived class
c. both a and b
d. only b
Answer Explanation
ANSWER: both a and b
Explanation:
No explanation is available for this question!
10) What is the difference between protected and private access specifiers in inheritance?
Explanation:
No explanation is available for this question!
11) A friend function does not have 'this' pointer associated with it.
a. True
b. False
Answer Explanation
ANSWER: True
Explanation:
No explanation is available for this question!
12) In nested try blocks, if both inner and outer catch handlers are not able to handle the
exception, then ______________ .
Explanation:
No explanation is available for this question!
13) Throwing an unhandled exception causes standard library function then _________ to
be invoked.
a. stop()
b. aborted()
c. terminate()
d. Abandon()
Answer Explanation
ANSWER: terminate()
Explanation:
No explanation is available for this question!
a. True
b. False
Answer Explanation
ANSWER: True
Explanation:
No explanation is available for this question!
15) When a class is defined inside any function or block, it is called ___________ .
a. Nested class
b. Block class
c. Local class
d. It is not possible
Answer Explanation
ANSWER: Local class
Explanation:
No explanation is available for this question!
16) Which of the followings are false statements about Local class?
1. A local class type name can only be used in the enclosing function
2. All the methods of Local classes must be defined inside the class only
3. A Local class can contain static data members.
4. A Local class may contain static functions.
5. Non-static variables of the enclosing function are not accessible inside local classes.
6. Local classes cannot access global types, variables and functions.
a. Only 1,3
b. Only 3, 6
c. Only 2 , 4 , 6
d. None of these
Answer Explanation
ANSWER: Only 3, 6
Explanation:
No explanation is available for this question!
a. True
b. False
Answer Explanation
ANSWER: True
Explanation:
No explanation is available for this question!
18) A const object of a class can call non-const member function of the class.
a. True
b. False
Answer Explanation
ANSWER: False
Explanation:
No explanation is available for this question!
Explanation:
No explanation is available for this question!
a. int
b. bool
c. char *
d. double
Answer Explanation
ANSWER: bool
Explanation:
No explanation is available for this question!
a. Yes
b. No
Answer Explanation
ANSWER: Yes
Explanation:
No explanation is available for this question!
a. function is defined
b. function is declared
c. Both a and b
d. None of these
Answer Explanation
ANSWER: function is declared
Explanation:
No explanation is available for this question!
23) Can member functions of one class be friend functions of another class?
a. Yes
b. No
Answer Explanation
ANSWER: Yes
Explanation:
No explanation is available for this question!
float x= 3.1496;
cout << setpricision(2) << x;
a. 3.14
b. 3.15
c. 3.00
d. None of these
Answer Explanation
ANSWER: None of these
Explanation:
No explanation is available for this question!
25) In case of binary operator overloading with member function, which of following
statement should be taken into consideration?
a. Yes
b. No
Answer Explanation
ANSWER: Yes
Explanation:
No explanation is available for this question!
2) Assume class TEST. Which of the following statements is/are responsible to invoke
copy constructor?
a. TEST T2(T1)
b. TEST T4 = T1
c. T2 = T1
d. both a and b
e. All of these
Answer Explanation
ANSWER: both a and b
Explanation:
No explanation is available for this question!
a. Zero
b. One
c. Two
d. None of these.
Answer Explanation
ANSWER: One
Explanation:
No explanation is available for this question!
4) In CPP program, Can we declare and define a user defined function inside a struct as
we do in a class ?
a. Yes
b. No
c. Can’t say
Answer Explanation
ANSWER: Yes
Explanation:
No explanation is available for this question!
5) ____________ refers to the act of representing only essential features without including
the background details.
a. Data Hiding
b. Data Encapsulation
c. Data Abstraction
d. All of these
Answer Explanation
ANSWER: Data Abstraction
Explanation:
No explanation is available for this question!
a. True
b. False
Answer Explanation
ANSWER: True
Explanation:
No explanation is available for this question!
Explanation:
No explanation is available for this question!
8) Assigning one or more function body to the same name is called ____________ .
a. Function Overriding
b. Function Overloading
c. Both a and b
d. None of the above
Answer Explanation
ANSWER: Function Overloading
Explanation:
No explanation is available for this question!
9) Function overloading can also be achieved if two or more functions differ only in their
return types.
a. True
b. False
Answer Explanation
ANSWER: False
Explanation:
No explanation is available for this question!
10) In nested try block, if inner catch handler gets executed, then _____________ .
Explanation:
No explanation is available for this question!
a. True
b. False
Answer Explanation
ANSWER: False
Explanation:
No explanation is available for this question!
12) Which of the following statements are not true about destructor?
a. Only 2, 3, 5
b. Only 2, 3, 4
c. Only 2, 4, 5
d. Only 3, 4, 5
Answer Explanation
ANSWER: Only 2, 4, 5
Explanation:
No explanation is available for this question!
13) When a child class inherits traits from more than one parent class, this type of
inheritance is called _______________ inheritance.
a. Hierarchical
b. Hybrid
c. Multilevel
d. Multiple
Answer Explanation
ANSWER: Multiple
Explanation:
No explanation is available for this question!
14) In case of inheritance where both base and derived class are having constructor and
destructor, then which if the following are true ?
a. Only 2 ,4
b. Only 1 , 3
c. Only 1 , 4
d. Only 2, 3
Answer Explanation
ANSWER: Only 1 , 4
Explanation:
No explanation is available for this question!
15) __________________ is the OOP feature and mechanism that binds together code and
the data it manipulates, and keep both safe from outside world.
a. Data Binding
b. Data Encapsulation
c. Data Storing
d. Data Abstraction
Answer Explanation
ANSWER: Data Encapsulation
Explanation:
No explanation is available for this question!
1. asm
2. boolean
3. mutable
4. export
5. constant_cast
a. Only 5
b. Only 1 and 4
c. Only 1,2 and 5
d. Only 2 and 5
Answer Explanation
ANSWER: Only 2 and 5
Explanation:
No explanation is available for this question!
a. True
b. False
Answer Explanation
ANSWER: False
Explanation:
No explanation is available for this question!
Explanation:
No explanation is available for this question!
19) If a class contains static variable, then every object of the class has its copy of static
variable.
a. True
b. False
Answer Explanation
ANSWER: False
Explanation:
No explanation is available for this question!
1. *
2. ::
3. ->*
4. ::*
5. ->
a. Only 1, 3, 4
b. Only 1 and 5
c. Only 3 and 4
d. Only 3,4,5
Answer Explanation
ANSWER: Only 1, 3, 4
Explanation:
No explanation is available for this question!
21) In Multipath inheritance, in order to remove duplicate set of records in child class, we
___________ .
Explanation:
No explanation is available for this question!
22) If base class has constructor with arguments, then it is ________________ for the
derived class to have constructor and pass the arguments to base class constructor.
a. Optional
b. Mandatory
c. Compiler dependent
d. Error
Answer Explanation
ANSWER: Mandatory
Explanation:
No explanation is available for this question!
23) Using friend operator function, following perfect set of operators may not be
overloaded.
a. = , ( ) , [ ] , ->
b. <<, = = , [ ] , >>
c. ?, = , ( ) , ++
d. None of these
Answer Explanation
ANSWER: = , ( ) , [ ] , ->
Explanation:
No explanation is available for this question!
a. iterator
b. allocator
c. constructor
d. operator
Answer Explanation
ANSWER: operator
Explanation:
No explanation is available for this question!
a. Yes
b. No
Answer Explanation
ANSWER: Yes
Explanation:
No explanation is available for this question!
2) The code of statements which may cause abnormal termination of the program should
be written under_________ block.
a. Try
b. catch
c. Finally
d. None of these
Answer Explanation
ANSWER: Try
Explanation:
No explanation is available for this question!
3) Object based language differs from object oriented language as it does not support
features _____ .
1. Encapsulation
2. Inheritance
3. Dynamic Binding
4. Abstraction
5. Polymorphism
a. only 3 ,4
b. only 1,3,5
c. 2,4,5
d. Only 2,3
Answer Explanation
ANSWER: Only 2,3
Explanation:
No explanation is available for this question!
a. Overloading
b. Overriding
c. Rewriting
d. All of these
Answer Explanation
ANSWER: Overriding
Explanation:
No explanation is available for this question!
5) In any ways, Non-member function cannot have access to the private data of the class.
a. True
b. False
Answer Explanation
ANSWER: False
Explanation:
No explanation is available for this question!
a. calloc()
b. malloc()
c. allocate
d. New
Answer Explanation
ANSWER: New
Explanation:
No explanation is available for this question!
a. Yes
b. No
Answer Explanation
ANSWER: Yes
Explanation:
No explanation is available for this question!
a. public
b. protected
c. private
d. struct can’t inherit class
Answer Explanation
ANSWER: public
Explanation:
No explanation is available for this question!
9) Which of the following manipulator is used for the representing octal equivalent of a
given decimal number?
a. oct
b. setbase(8)
c. tobase(8)
d. both a and b
e. all a, b, c
Answer Explanation
ANSWER: both a and b
Explanation:
No explanation is available for this question!
a. explicit_cast
b. static_cast
c. dynamic_cast
d. reinterpret_cast
Answer Explanation
ANSWER: explicit_cast
Explanation:
No explanation is available for this question!
a. < iomanipulator.h>
b. < stdiomanip.h>
c. < stdmanip.h>
d. < iomanip.h>
Answer Explanation
ANSWER: < iomanip.h>
Explanation:
No explanation is available for this question!
12) While redefining a virtual function in the derived class, if its prototype is changed then
___________________ .
Explanation:
No explanation is available for this question!
13) const member function does not allow to modify/alter value of any data member of the
class.
a. True
b. False
Answer Explanation
ANSWER: True
Explanation:
No explanation is available for this question!
14) In a program, If there exists a function template with two parameters and normal
function say void add(int , int), so add(3,4) will _____________________ .
Explanation:
No explanation is available for this question!
a. Yes
b. No
Answer Explanation
ANSWER: Yes
Explanation:
No explanation is available for this question!
16) In case of inheritance where both base and derived class are having constructors,
when an object of derived class is created then___________ .
Explanation:
No explanation is available for this question!
a. ios::ate
b. ios::nocreate
c. ios::noreplace
d. ios::truncate
Answer Explanation
ANSWER: ios::truncate
Explanation:
No explanation is available for this question!
18) Attempting to throw an exception that is not supported by a function call results in
calling _____________ library function.
a. indeterminate()
b. unutilized()
c. unexpected()
d. unpredicted()
Answer Explanation
ANSWER: unexpected()
Explanation:
No explanation is available for this question!
Explanation:
No explanation is available for this question!
a. Yes
b. No
Answer Explanation
ANSWER: Yes
Explanation:
No explanation is available for this question!
21) The purpose of explicit keyword is to tell the compiler that a certain constructor may
not be used to implicitly cast an expression to its class type.
a. True
b. False
Answer Explanation
ANSWER: True
Explanation:
No explanation is available for this question!
Explanation:
No explanation is available for this question!
a. Only 2
b. Only 1, 3
c. Only 2 , 3
d. All 1 , 2, 3
Answer Explanation
ANSWER: Only 2 , 3
Explanation:
No explanation is available for this question!
a. True
b. False
Answer Explanation
ANSWER: True
Explanation:
No explanation is available for this question!
25) In nested try blocks, there is no need to specify catch handler for inner try block.
Outer catch handler is sufficient for the program.
a. True
b. False
Answer Explanation
ANSWER: False
a. True
b. False
Answer Explanation
ANSWER: True
Explanation:
No explanation is available for this question!
2) Functions called from within a try block may also throw exception.
a. True
b. False
Answer Explanation
ANSWER: True
Explanation:
No explanation is available for this question!
3) The explicit keyword is an optional decoration for the constructors that takes
exactly_____argument.
a. No argument
b. Two
c. Three
d. One
Answer Explanation
ANSWER: One
Explanation:
No explanation is available for this question!
4) A class can contain objects of other classes and this phenomenon is called_________ .
a. Relationship
b. Object Association
c. Containership
d. None of these
Answer Explanation
ANSWER: Containership
Explanation:
No explanation is available for this question!
5) Can we alter/modify the values of data members of a class inside const member
function?
a. Yes
b. No
Answer Explanation
ANSWER: Yes
Explanation:
No explanation is available for this question!
a. Virtual class
b. Sealed class
c. Pure Local class
d. Abstract Class
Answer Explanation
ANSWER: Abstract Class
Explanation:
No explanation is available for this question!
Explanation:
No explanation is available for this question!
a. catch(..,)
b. catch(---)
c. catch(…)
d. catch( void x)
Answer Explanation
ANSWER: catch(…)
Explanation:
No explanation is available for this question!
Explanation:
No explanation is available for this question!
10) It is not possible to combine two or more file opening mode in open () method.
a. True
b. False
Answer Explanation
ANSWER: False
Explanation:
No explanation is available for this question!
a. True
b. False
Answer Explanation
ANSWER: False
Explanation:
No explanation is available for this question!
12) While overloading binary operators using member function, it requires ___
argument/s.
a. Zero
b. One
c. Two
d. Three
Answer Explanation
ANSWER: One
Explanation:
No explanation is available for this question!
a. Derived class should provide definition for all the pure virtual functions
b. Derived class also become abstract if fails to implement pure virtual functions
c. Objects of derived class can’t be created if it fails to implement pure virtual functions
d. All of these
Answer Explanation
ANSWER: All of these
Explanation:
No explanation is available for this question!
14) By default, all the files are opened in ___________mode .
a. Binary
b. Text
c. Can’t say
Answer Explanation
ANSWER: Text
Explanation:
No explanation is available for this question!
15) Generic catch handler must be placed at the end of all the catch handlers.
a. True
b. False
Answer Explanation
ANSWER: True
Explanation:
No explanation is available for this question!
a. True
b. False
Answer Explanation
ANSWER: False
Explanation:
No explanation is available for this question!
17) The CPP compiler supports automatic type conversions for the user defined
datatypes.
a. True
b. False
Answer Explanation
ANSWER: False
Explanation:
No explanation is available for this question!
a. Yes
b. No
Answer Explanation
ANSWER: Yes
Explanation:
No explanation is available for this question!
19) Can we pass parameters to base class constructor though derived class or derived
class constructor?
a. Yes
b. No
Answer Explanation
ANSWER: Yes
Explanation:
No explanation is available for this question!
a. Inheritance
b. Virtual Functions
c. Templates
d. None of these
Answer Explanation
ANSWER: Templates
Explanation:
No explanation is available for this question!
21) Irrespective of exception occurrence, catch handler will always get executed.
a. True
b. False
Answer Explanation
ANSWER: False
Explanation:
No explanation is available for this question!
22) In CPP, cin and cout are the predefined stream __________ .
a. Operator
b. Functions
c. Objects
d. Data types
Answer Explanation
ANSWER: Objects
Explanation:
No explanation is available for this question!
a. top-down
b. procedural
c. bottom-up
d. all of these.
Answer Explanation
ANSWER: bottom-up
Explanation:
No explanation is available for this question!
a. enum
b. const
c. #define
d. All of these
e. None of these
Answer Explanation
ANSWER: All of these
Explanation:
No explanation is available for this question!
25) A virtual function that has no definition within the base class is called____________.
Here, you can read C++ basic concepts multiple choice questions and answers with explanation.
a. enum
b. const
c. #define
d. All of these
e. None of these
Answer Explanation
ANSWER: All of these
Explanation:
No explanation is available for this question!
a. top-down
b. procedural
c. bottom-up
d. all of these.
Answer Explanation
ANSWER: bottom-up
Explanation:
No explanation is available for this question!
a. Operator
b. Functions
c. Objects
d. Data types
Answer Explanation
ANSWER: Objects
Explanation:
No explanation is available for this question!
a. Inheritance
b. Virtual Functions
c. Templates
d. None of these
Answer Explanation
ANSWER: Templates
Explanation:
No explanation is available for this question!
a. Yes
b. No
Answer Explanation
ANSWER: Yes
Explanation:
No explanation is available for this question!
6) The CPP compiler supports automatic type conversions for the user defined datatypes.
- Published on 19 Oct 15
a. True
b. False
Answer Explanation
ANSWER: False
Explanation:
No explanation is available for this question!
Explanation:
No explanation is available for this question!
8) A class can contain objects of other classes and this phenomenon is called_________ .
- Published on 19 Oct 15
a. Relationship
b. Object Association
c. Containership
d. None of these
Answer Explanation
ANSWER: Containership
Explanation:
No explanation is available for this question!
9) While redefining a virtual function in the derived class, if its prototype is changed then
___________________ .
- Published on 19 Jul 15
Explanation:
No explanation is available for this question!
10) Object based language differs from object oriented language as it does not support
features _____ .
1. Encapsulation
2. Inheritance
3. Dynamic Binding
4. Abstraction
5. Polymorphism
- Published on 19 Jul 15
a. only 3 ,4
b. only 1,3,5
c. 2,4,5
d. Only 2,3
Answer Explanation
Here, you can read C++ basic concepts multiple choice questions and answers with explanation.
Explanation:
No explanation is available for this question!
12) If a class contains static variable, then every object of the class has its copy of static
variable.
- Published on 17 Jul 15
a. True
b. False
Answer Explanation
ANSWER: False
Explanation:
No explanation is available for this question!
13) Which of the followings is/are not keyword/s in CPP?
1. asm
2. boolean
3. mutable
4. export
5. constant_cast
- Published on 17 Jul 15
a. Only 5
b. Only 1 and 4
c. Only 1,2 and 5
d. Only 2 and 5
Answer Explanation
ANSWER: Only 2 and 5
Explanation:
No explanation is available for this question!
14) __________________ is the OOP feature and mechanism that binds together code and
the data it manipulates, and keep both safe from outside world.
- Published on 17 Jul 15
a. Data Binding
b. Data Encapsulation
c. Data Storing
d. Data Abstraction
Answer Explanation
ANSWER: Data Encapsulation
Explanation:
No explanation is available for this question!
15) ____________ refers to the act of representing only essential features without
including the background details.
- Published on 17 Jul 15
a. Data Hiding
b. Data Encapsulation
c. Data Abstraction
d. All of these
Answer Explanation
ANSWER: Data Abstraction
Explanation:
No explanation is available for this question!
16) In CPP program, Can we declare and define a user defined function inside a struct as
we do in a class ?
- Published on 17 Jul 15
a. Yes
b. No
c. Can’t say
Answer Explanation
ANSWER: Yes
Explanation:
No explanation is available for this question!
17) Which of the followings are false statements about Local class?
1. A local class type name can only be used in the enclosing function
2. All the methods of Local classes must be defined inside the class only
3. A Local class can contain static data members.
4. A Local class may contain static functions.
5. Non-static variables of the enclosing function are not accessible inside local classes.
6. Local classes cannot access global types, variables and functions.
- Published on 17 Jul 15
a. Only 1,3
b. Only 3, 6
c. Only 2 , 4 , 6
d. None of these
Answer Explanation
ANSWER: Only 3, 6
Explanation:
No explanation is available for this question!
18) When a class is defined inside any function or block, it is called ___________ .
- Published on 17 Jul 15
a. Nested class
b. Block class
c. Local class
d. It is not possible
Answer Explanation
ANSWER: Local class
Explanation:
No explanation is available for this question!
a. True
b. False
Answer Explanation
ANSWER: True
Explanation:
No explanation is available for this question!
20) We can initialize a value of static variable of a class only when its object is created. No
other initialization is permitted.
- Published on 17 Jul 15
a. True
b. False
Answer Explanation
ANSWER: False
Here, you can read C++ basic concepts multiple choice questions and answers with explanation.
a. explicit
b. garbage
c. bool
d. static
Answer Explanation
ANSWER: bool
Explanation:
No explanation is available for this question!
22) Only functions of the class can access the data of the class and they(functions)
provides the interface between data, objects and the program. This kind isolation of the
data from direct access by the program is called _______________ .
- Published on 17 Jul 15
a. Data Abstraction
b. Data Hiding
c. Data Binding
d. Data Encapsulation
Answer Explanation
ANSWER: Data Hiding
Explanation:
No explanation is available for this question!
23) Public data members and member functions of the class are accessible ONLY to the
member functions of that class.
- Published on 17 Jul 15
a. True
b. False
Answer Explanation
ANSWER: False
Explanation:
No explanation is available for this question!
int x = 786;
cout << setfill(‘*’) << setw(6) << x;
- Published on 17 Jul 15
a. 786***
b. **786
c. ***786
d. ******
Answer Explanation
ANSWER: ***786
Explanation:
No explanation is available for this question!
25) Private members of the class are accessible only to the members of the same class.
- Published on 17 Jul 15
a. True
b. False
Answer Explanation
ANSWER: False
Explanation:
No explanation is available for this question!
a. instance variable
b. named constant
c. global variable
d. class variable
Answer Explanation
ANSWER: class variable
Explanation:
No explanation is available for this question!
a. True
b. False
Answer Explanation
ANSWER: False
Explanation:
No explanation is available for this question!
28) Which of the following are true about static member function?
a. Only 2
b. Only 2,5
c. Only 2,3,4,5
d. Only 2 , 3 , 5
e. All of these
Answer Explanation
ANSWER: Only 2 , 3 , 5
Explanation:
No explanation is available for this question!
29) C structure differs from CPP class in regards that by default all the members of the
structure are __________ in nature.
- Published on 17 Jul 15
a. private
b. protected
c. public
d. None of these
Answer Explanation
ANSWER: public
Explanation:
No explanation is available for this question!
30) Members of the class can be declared with auto, extern or register storage classes.
- Published on 17 Jul 15
a. True
b. False
Answer Explanation
ANSWER: False
Here, you can read C++ basic concepts multiple choice questions and answers with explanation.
1. flush
2. base
3. ends
4. oct
5. bin
6. skipws
- Published on 17 Jul 15
a. Only 1, 6
b. Only 1,4,6
c. Only 1,3,6
d. Only 2,5
Answer Explanation
ANSWER: Only 2,5
Explanation:
No explanation is available for this question!
Explanation:
No explanation is available for this question!
33) In CPP, the size of the character array should be one larger than the number of
characters in the string.
- Published on 17 Jul 15
a. True
b. False
Answer Explanation
ANSWER: True
Explanation:
No explanation is available for this question!
34) If a program uses Inline Function, then the function is expanded inline at
___________.
- Published on 17 Jul 15
a. Compile time
b. Run time
c. Both a and b
d. None of these
Answer Explanation
ANSWER: Run time
Explanation:
No explanation is available for this question!
a. per = total/(float)m
b. per = total/float(m)
c. per = (float)total/m
d. None of these
Answer Explanation
ANSWER: per = total/float(m)
Explanation:
No explanation is available for this question!
private:
int m1, m2, m3;
};
- Published on 17 Jul 15
a. Yes
b. No
Answer Explanation
ANSWER: Yes
Explanation:
No explanation is available for this question!
a. protected
b. private
c. public
d. static
Answer Explanation
ANSWER: private
Explanation:
No explanation is available for this question!
a. Iterators
b. Punctuators
c. Manipulators
d. Allocators
Answer Explanation
ANSWER: Manipulators
Explanation:
No explanation is available for this question!
a. 0
b. 1
c. Garbage value
d. Compiler dependent
Answer Explanation
ANSWER: 0
Here, you can read Constructor and Destructor multiple choice questions and answers with
explanation.
1) The explicit keyword is an optional decoration for the constructors that takes
exactly_____argument.
- Published on 19 Oct 15
a. No argument
b. Two
c. Three
d. One
Answer Explanation
ANSWER: One
Explanation:
No explanation is available for this question!
2) The purpose of explicit keyword is to tell the compiler that a certain constructor may
not be used to implicitly cast an expression to its class type.
- Published on 19 Jul 15
a. True
b. False
Answer Explanation
ANSWER: True
Explanation:
No explanation is available for this question!
a. Yes
b. No
Answer Explanation
ANSWER: Yes
Explanation:
No explanation is available for this question!
a. Only 2, 3, 5
b. Only 2, 3, 4
c. Only 2, 4, 5
d. Only 3, 4, 5
Answer Explanation
ANSWER: Only 2, 4, 5
Explanation:
No explanation is available for this question!
5) Assume class TEST. Which of the following statements is/are responsible to invoke
copy constructor?
- Published on 17 Jul 15
a. TEST T2(T1)
b. TEST T4 = T1
c. T2 = T1
d. both a and b
e. All of these
Answer Explanation
ANSWER: both a and b
Explanation:
No explanation is available for this question!
a. Yes
b. No
Answer Explanation
ANSWER: Yes
Explanation:
No explanation is available for this question!
Explanation:
No explanation is available for this question!
a. Only 1,2,4
b. 1,2,4,5
c. 1,3,5
d. 1,4,5
Answer Explanation
ANSWER: 1,4,5
Explanation:
No explanation is available for this question!
a. Yes
b. No
Answer Explanation
ANSWER: Yes
Explanation:
No explanation is available for this question!
10) If default constructor is not defined, then how the objects of the class will be created?
- Published on 17 Jul 15
Here, you can read Inheritance multiple choice questions and answers with explanation.
1) Can we pass parameters to base class constructor though derived class or derived
class constructor?
- Published on 19 Oct 15
a. Yes
b. No
Answer Explanation
ANSWER: Yes
Explanation:
No explanation is available for this question!
a. True
b. False
Answer Explanation
ANSWER: False
Explanation:
No explanation is available for this question!
3) In case of inheritance where both base and derived class are having constructors, when
an object of derived class is created then___________ .
- Published on 19 Jul 15
Explanation:
No explanation is available for this question!
a. Yes
b. No
Answer Explanation
ANSWER: Yes
Explanation:
No explanation is available for this question!
a. public
b. protected
c. private
d. struct can’t inherit class
Answer Explanation
ANSWER: public
Explanation:
No explanation is available for this question!
6) If base class has constructor with arguments, then it is ________________ for the
derived class to have constructor and pass the arguments to base class constructor.
- Published on 17 Jul 15
a. Optional
b. Mandatory
c. Compiler dependent
d. Error
Answer Explanation
ANSWER: Mandatory
Explanation:
No explanation is available for this question!
Explanation:
No explanation is available for this question!
8) In case of inheritance where both base and derived class are having constructor and
destructor, then which if the following are true ?
a. Only 2 ,4
b. Only 1 , 3
c. Only 1 , 4
d. Only 2, 3
Answer Explanation
ANSWER: Only 1 , 4
Explanation:
No explanation is available for this question!
9) When a child class inherits traits from more than one parent class, this type of
inheritance is called _______________ inheritance.
- Published on 17 Jul 15
a. Hierarchical
b. Hybrid
c. Multilevel
d. Multiple
Answer Explanation
ANSWER: Multiple
Explanation:
No explanation is available for this question!
10) What is the difference between protected and private access specifiers in inheritance?
- Published on 17 Jul 15
a. private member is not inheritable and not accessible in derived class.
b. protected member is inheritable and also accessible in derived class.
c. Both are inheritable but private is accessible in the derived class.
d. Both are inheritable but protected is not accessible in the derived class.
Answer Explanation
ANSWER: protected member is inheritable and also accessible in derived class
Here, you can read Inheritance multiple choice questions and answers with explanation.
11) When a base class is privately inherited by the derived class, then_____________ .
- Published on 17 Jul 15
a. protected members of the base class become private members of derived class
b. public members of the base class become private members of derived class
c. both a and b
d. only b
Answer Explanation
ANSWER: both a and b
Explanation:
No explanation is available for this question!
12) The derivation of Child class from Base class is indicated by ____ symbol.
- Published on 17 Jul 15
a. ::
b. :
c. ;
d. |
Answer Explanation
ANSWER: :
Explanation:
No explanation is available for this question!
13) During a class inheritance in CPP, if the visibility mode or mode of derivation is not
provided, then by default visibility mode is ___________.
- Published on 17 Jul 15
a. public
b. protected
c. private
d. Friend
Answer Explanation
ANSWER: private
Explanation:
No explanation is available for this question!
- Published on 17 Jul 15
a. Only 1, 5
b. Only 1, 6
c. Only 2, 6
d. Only 2, 4
Answer Explanation
ANSWER: Only 2, 4
Explanation:
No explanation is available for this question!
15) class X, class Y and class Z are derived from class BASE. This is ______ inheritance.
- Published on 17 Jul 15
a. Multiple
b. Multilevel
c. Hierarchical
d. Single
Answer Explanation
ANSWER: Hierarchical
Explanation:
No explanation is available for this question!
a. Polymorphism
b. Encapsulation
c. Inheritance
d. Both a and c
Answer Explanation
ANSWER: Inheritance
Here, you can read File Handling multiple choice questions and answers with explanation.
a. Binary
b. Text
c. Can’t say
Answer Explanation
ANSWER: Text
Explanation:
No explanation is available for this question!
2) It is not possible to combine two or more file opening mode in open () method.
- Published on 19 Oct 15
a. True
b. False
Answer Explanation
ANSWER: False
Explanation:
No explanation is available for this question!
a. ios::ate
b. ios::nocreate
c. ios::noreplace
d. ios::truncate
Answer Explanation
ANSWER: ios::truncate
Explanation:
No explanation is available for this question!
a. True
b. False
Answer Explanation
ANSWER: True
Explanation:
No explanation is available for this question!
5) If we have object from ofstream class, then default mode of opening the file is _____ .
- Published on 17 Jul 15
a. ios::in
b. ios::out
c. ios::in|ios::trunc
d. ios::out|ios::trunk
Answer Explanation
ANSWER: ios::out|ios::trunk
Explanation:
No explanation is available for this question!
a. int
b. bool
c. float
d. char *
Answer Explanation
ANSWER: bool
Explanation:
No explanation is available for this question!
7) If we have object from fstream class, then what is the default mode of opening the file?
- Published on 17 Jul 15
a. ios::in|ios::out
b. ios::in|ios::out|ios::trunc
c. ios::in|ios::trunc
d. Default mode depends on compiler
Answer Explanation
ANSWER: Default mode depends on compiler
Explanation:
No explanation is available for this question!
a. ofstream
b. ifstream
c. iostream
d. None of these
Answer Explanation
ANSWER: ofstream
Explanation:
No explanation is available for this question!
9) Streams that will be performing both input and output operations must be declared as
class _________ .
- Published on 17 Jul 15
a. iostream
b. fstream
c. stdstream
d. Stdiostream
Answer Explanation
ANSWER: fstream
Explanation:
No explanation is available for this question!
10) To perform File I/O operations, we must use _____________ header file.
- Published on 17 Jul 15
a. < ifstream>
b. < ofstream>
c. < fstream>
d. Any of these
Answer Explanation
ANSWER: < fstream>
11) Which of the following is not used to seek a file pointer?
- Published on 17 Jul 15
a. ios::cur
b. ios::set
c. ios::end
d. ios::beg
Answer Explanation
ANSWER: ios::set
Here, you can read Memory Management multiple choice questions and answers with
explanation.
a. Yes
b. No
Answer Explanation
ANSWER: Yes
Explanation:
No explanation is available for this question!
a. calloc()
b. malloc()
c. allocate
d. New
Answer Explanation
ANSWER: New
Explanation:
No explanation is available for this question!
a. It can’t be overloaded.
b. It returns garbage value when memory allocation fails.
c. It automatically computes the size of the data object.
d. All of these
Answer Explanation
ANSWER: It automatically computes the size of the data object.
Explanation:
No explanation is available for this question!
4) Which of the following operator is used to release the dynamically allocated memory in
CPP?
- Published on 17 Jul 15
a. remove
b. free
c. delete
d. both b and c
Answer Explanation
ANSWER: delete
Explanation:
No explanation is available for this question!
5) Which of the following is/are valid ways to allocate memory for an integer by dynamic
memory allocation in CPP?
- Published on 17 Jul 15
Explanation:
No explanation is available for this question!
6) During dynamic memory allocation in CPP, new operator returns _________ value if
memory allocation is unsuccessful.
- Published on 17 Jul 15
a. False
b. NULL
c. Zero
d. None of these
Answer Explanation
ANSWER: NULL
Here, you can read Operator Overloading multiple choice questions and answers with
explanation.
a. Zero
b. One
c. Two
d. Three
Answer Explanation
ANSWER: One
Explanation:
No explanation is available for this question!
a. Only 2
b. Only 1, 3
c. Only 2 , 3
d. All 1 , 2, 3
Answer Explanation
ANSWER: Only 2 , 3
Explanation:
No explanation is available for this question!
Explanation:
No explanation is available for this question!
a. < iomanipulator.h>
b. < stdiomanip.h>
c. < stdmanip.h>
d. < iomanip.h>
Answer Explanation
ANSWER: < iomanip.h>
Explanation:
No explanation is available for this question!
a. explicit_cast
b. static_cast
c. dynamic_cast
d. reinterpret_cast
Answer Explanation
ANSWER: explicit_cast
Explanation:
No explanation is available for this question!
6) Which of the following manipulator is used for the representing octal equivalent of a
given decimal number?
- Published on 19 Jul 15
a. oct
b. setbase(8)
c. tobase(8)
d. both a and b
e. all a, b, c
Answer Explanation
ANSWER: both a and b
Explanation:
No explanation is available for this question!
a. iterator
b. allocator
c. constructor
d. operator
Answer Explanation
ANSWER: operator
Explanation:
No explanation is available for this question!
8) Using friend operator function, following perfect set of operators may not be
overloaded.
- Published on 17 Jul 15
a. = , ( ) , [ ] , ->
b. <<, = = , [ ] , >>
c. ?, = , ( ) , ++
d. None of these
Answer Explanation
ANSWER: = , ( ) , [ ] , ->
Explanation:
No explanation is available for this question!
a. Zero
b. One
c. Two
d. None of these.
Answer Explanation
ANSWER: One
Explanation:
No explanation is available for this question!
10) In case of binary operator overloading with member function, which of following
statement should be taken into consideration?
- Published on 17 Jul 15
11) Which of the following is the perfect set of operators that can’t be overloaded in CPP
?
- Published on 17 Jul 15
a. +=, ?, :: , >>
b. >>, <<, ?, *, sizeof()
c. :: , . , .* , ?:
d. :: , ->, * , new, delete
Answer Explanation
ANSWER: :: , . , .* , ?:
Here, you can read Polymorphism and Abstract Classes multiple choice questions and answers
with explanation.
1) A virtual function that has no definition within the base class is called____________.
- Published on 19 Oct 15
Explanation:
No explanation is available for this question!
a. Derived class should provide definition for all the pure virtual functions
b. Derived class also become abstract if fails to implement pure virtual functions
c. Objects of derived class can’t be created if it fails to implement pure virtual functions
d. All of these
Answer Explanation
ANSWER: All of these
Explanation:
No explanation is available for this question!
a. Virtual class
b. Sealed class
c. Pure Local class
d. Abstract Class
Answer Explanation
ANSWER: Abstract Class
Explanation:
No explanation is available for this question!
a. Overloading
b. Overriding
c. Rewriting
d. All of these
Answer Explanation
ANSWER: Overriding
Explanation:
No explanation is available for this question!
Explanation:
No explanation is available for this question!
a. True
b. False
Answer Explanation
ANSWER: False
Explanation:
No explanation is available for this question!
Explanation:
No explanation is available for this question!
a. True
b. False
Answer Explanation
ANSWER: True
Explanation:
No explanation is available for this question!
Explanation:
No explanation is available for this question!
10) _______________ is a member function that is declared within a base class and
redefined by derived class.
- Published on 17 Jul 15
a. virtual function
b. static function
c. friend function
d. const member function
Answer Explanation
ANSWER: virtual function
Here, you can read Polymorphism and Abstract Classes multiple choice questions and answers
with explanation.
Explanation:
No explanation is available for this question!
a. True
b. False
Answer Explanation
ANSWER: False
Here, you can read Functions multiple choice questions and answers with explanation.
1) Can we alter/modify the values of data members of a class inside const member
function?
- Published on 19 Oct 15
a. Yes
b. No
Answer Explanation
ANSWER: Yes
Explanation:
No explanation is available for this question!
2) In a program, If there exists a function template with two parameters and normal
function say void add(int , int), so add(3,4) will _____________________ .
- Published on 19 Jul 15
Explanation:
No explanation is available for this question!
3) const member function does not allow to modify/alter value of any data member of the
class.
- Published on 19 Jul 15
a. True
b. False
Answer Explanation
ANSWER: True
Explanation:
No explanation is available for this question!
4) In any ways, Non-member function cannot have access to the private data of the class.
- Published on 19 Jul 15
a. True
b. False
Answer Explanation
ANSWER: False
Explanation:
No explanation is available for this question!
a. True
b. False
Answer Explanation
ANSWER: False
Explanation:
No explanation is available for this question!
6) Function overloading can also be achieved if two or more functions differ only in their
return types.
- Published on 17 Jul 15
a. True
b. False
Answer Explanation
ANSWER: False
Explanation:
No explanation is available for this question!
7) Assigning one or more function body to the same name is called ____________ .
- Published on 17 Jul 15
a. Function Overriding
b. Function Overloading
c. Both a and b
d. None of the above
Answer Explanation
ANSWER: Function Overloading
Explanation:
No explanation is available for this question!
float x= 3.1496;
cout << setpricision(2) << x;
- Published on 17 Jul 15
a. 3.14
b. 3.15
c. 3.00
d. None of these
Answer Explanation
ANSWER: None of these
Explanation:
No explanation is available for this question!
a. Yes
b. No
Answer Explanation
ANSWER: Yes
Explanation:
No explanation is available for this question!
a. function is defined
b. function is declared
c. Both a and b
d. None of these
Answer Explanation
ANSWER: function is declared
Here, you can read Functions multiple choice questions and answers with explanation.
Explanation:
No explanation is available for this question!
12) A const object of a class can call non-const member function of the class.
- Published on 17 Jul 15
a. True
b. False
Answer Explanation
ANSWER: False
Explanation:
No explanation is available for this question!
13) A friend function does not have 'this' pointer associated with it.
- Published on 17 Jul 15
a. True
b. False
Answer Explanation
ANSWER: True
Explanation:
No explanation is available for this question!
14) Default values for a function are need to be specified from left to right only.
- Published on 17 Jul 15
a. True
b. False
Answer Explanation
ANSWER: False
Explanation:
No explanation is available for this question!
a. void
b. long
c. char
d. Int
Answer Explanation
ANSWER: Int
Explanation:
No explanation is available for this question!
16) Which of the followings is/are not false about friend function ?
- Published on 17 Jul 15
a. Only 2,4
b. Only 1,2,5
c. Only 2,3,5
d. All of these
Answer Explanation
ANSWER: Only 2,3,5
Explanation:
No explanation is available for this question!
17) Inline functions may not work ______ .
a. Only 1,4,5
b. Only 2,3,5
c. Only 1,3,4
d. All of these
Answer Explanation
ANSWER: Only 1,3,4
Explanation:
No explanation is available for this question!
a. Yes
b. No
Answer Explanation
ANSWER: Yes
Explanation:
No explanation is available for this question!
19) By default, if a function with minimum lines of code is declared and defined inside the
class becomes Inline function.
- Published on 17 Jul 15
a. True
b. False
Answer Explanation
ANSWER: True
Explanation:
No explanation is available for this question!
20) Which of the following best defines the syntax for template function ?
- Published on 17 Jul 15
a. Template
b. Template return_type Function_Name(Parameters)
c. Both a and b
d. None of these
Answer Explanation
ANSWER: Both a and b
A. int array[10];
B. int array;
C. array{10};
D. array array[10];
View Answer
Workspace
Report
Discuss
2. What is the index number of the last element of an array with 9 elements?
A. 9
B. 8
C. 0
D. Programmer-defined
View Answer
Workspace
Report
Discuss
3. What is a array?
View Answer
Workspace
Report
Discuss
4. Which of the following accesses the seventh element stored in array?
A. array[6];
B. array[7];
C. array(7);
D. array;
View Answer
Workspace
Report
Discuss
5. Which of the following gives the memory address of the first element in array?
A. array[0];
B. array[1];
C. array(2);
D. array;
View Answer
Workspace
Report
Discuss
Answer: Option D
Explanation:
array;
A. Pass by value
B. Pass by reference
C. Pass by pointer
D. All the above
View Answer
Answer: D
In C++ programming, all pass by value, reference and pointer are used. Note that pass by reference in C
Programming language is not available. However, sometimes people use the term pass by reference
instead of pass by address or pass by pointers. Read here pass by value and pass by pointer in C
programming and difference between pass by pointer and pass by reference in C++ language.
A. void display()
B. void display() const
C. const void display()
D. void const display()
View Answer
Answer: B
Constant function in a class is used to prevent modification of class member variables inside its
body. When we only want to read member variable and use it in function body with no
modification then we should use const function. Read detail of constant function in C++ object
oriented programming.
Q) True and false statements about inline function in given C++ code example is/are
(I)Static function of a class can be called by class name using scope resolution operator i.e. : :
(II)Static function can receive both static and non-static data members of a class
(III)Static function is not the part of an object of a class
A. I and II
B. I only
C. I and III
D. I, II and III
View Answer
Answer: C
Read in detail about static function in C++ with example and if static function can access
non static data in C++ program.
Q) Which of the following functions are provided by compiler by default if we don’t write in a C++
class?
A. Copy constructor
B. Assignment
C. Constructor
D. All the above
View Answer
Answer: D
All functions are provided by compiler if we don’t write in a class. Read more on default
functions provided by compiler in C++
A. Static function
B. Inline function
C. Friend function
D. constant function
View Answer
Answer: A
View Answer
Answer: C
A. Virtual function
B. Inline function
C. Static function
D. constant function
View Answer
Answer: C
View Answer
Answer: A
Explanation:Default arguments in a function in C++ program is initialized from right to left.
A. Virtual function
B. member function
C. Static function
D. All can be overloaded
View Answer
Answer: C
Static functions cannot be overloaded in C++ programming. You can read static function in C++ and how
it differs from C.
Q) Choose the correct answer for following piece of C++ pseudo code
void func(int a, int &b)
{
int main(){
int a,b;
func(a,b);
}
View Answer
Answer: A
B parameter is not pass by address/pointer but reference. Here is the correct pseudo code for pass by
address or say pointer.
int main(){
int a,b;
func(a,&b);
}
View Answer
Answer: C
Function overloading is compile time polymorphism in which 2 or more functions share the same name
with different arguments and parameters in C++ oops.
Recommended to read function overloading in C++
NOTE: In C++, constructor is also a special type of function that can be overloaded. You can
read advantage of constructor overloading in C++ applications.
View Answer
Answer: A
A is the correct declaration of pure virtual function in a class in C++
A. Car obj;
B. Car *obj = new Car();
C. Only B
D. A & B both
View Answer
Answer: D
Both Car obj; and Car *obj = new Car() are valid way to create an object of the class.
Q) In C++, Class object created statically(e.g. Car obj; and dynamically (Car *obj = new Car() ; ) are
stored in memory
A. Stack, heap
B. Heap, heap
C. Heap, stack
D. Stack, stack
View Answer
Answer: A
View Answer
Answer: A
A. Function
B. Operator
C. Object
D. macro
View Answer
Answer: C
A. Class
B. Int
C. Float
D. array
View Answer
Answer: A
Q) Class allows only one object of it to be created though out the program life cycle
A. Singleton class
B. Abstract class
C. Friend class
D. All classes
View Answer
Answer: A
View Answer
Answer: B
Q) When you create an object of a class A like A obj ; then which one will be called automatically
A. Constructor
B. Destructor
C. Copy constructor
D. Assignment operator
View Answer
Answer: A
A. Derived class constructor is called first then the base class constructor
B. Base class constructor is called first then derived class constructor
C. base class constructor will not be called
D. none of the above
View Answer
Answer: B
Q) The class in C++ which act only as a base class and object of it cannot be created is
A. parent class
B. super class
C. abstract class
D. none of the above
View Answer
Answer: C
Q) Data members and member functions of a class in C++ program are by default
A. protected
B. public
C. private
D. None
View Answer
Answer: C
View Answer
Answer: C
A. :
B. ::
C. #
D. None
View Answer
Answer: B
A. An interface
B. An Abstract class
C. A singleton class
D. A&B
E. A, B & C
View Answer
Answer: D
A. Constructor
B. Destructor
C. Copy constructor
D. Assignment operator
E. All
View Answer
Answer: E
Q) The OOPs concept in C++, exposing only necessary information to users or clients is known as
A. Abstraction
B. Encapsulation
C. Data hiding
D. Hiding complexity
View Answer
Answer: A
Q) Which of the following is an abstract data type?
A. Class
B. Int
C. String
D. Double
View Answer
Answer: A
A. Abstraction
B. Encapsulation
C. Data hiding
D. Composition
View Answer
Answer: B
View Answer
Answer: A
A. Composition
B. Inheritance
C. Encapsulation
D. None
View Answer
Answer: A
In simple word, if a class contains an object of another class as a data member, then it is known
as composition. For example,
Class Y, have a class X’s object as data member. Means, Y is composed of X.
class X {
public:
void f1() {
}
};
class Y{
X obj;//class object as a data member
public:
void f2() {
}
};
Another example,we can take that a house is composed of windows, door and bricks etc. So,
class House will look like below
class Door {
};
class Windows {
};
class Bricks {
};
class House{
Door _d;
Windows _w;
Bricks _b;
public:
void showHouse() {
}
};
A. Virtual destructor
B. Virtual constructor
C. Virtual function
D. All
View Answer
Answer: B
Q) IS A relationship in C++ is
A. Inheritance
B. Encapsulation
C. Composition
D. None
View Answer
Answer: A
Q) If you want to write multiple functions in a class with same name, then what C++ feature will you
use?
A. Function overriding
B. Encapsulation
C. Function overloading
D. None
View Answer
Answer: C
Compile time polymorphism feature is used i.e. function overloading in C++. Function
overloading means, in a class, multiple functions with same name can be written with different
signatures, return types etc.
A. Compile time
B. Run time
C. Both
D. None
View Answer
Answer: C
Two types of Polymorphism are available in C++ object oriented programming i.e. compile time
and run time polymorphism. Also, known as early binding and late binding respectively.
Compiler time polymorphism features in C++ language are function overloading, constructor
and operator overloading etc. and run time polymorphism is function overriding in inheritance
relationship.
Q) If I want to have common functions in a class and want to defer implementations of some other
functions to derived classes, then we need to use
A. An interface
B. An abstract class
C. A friend class
D. A static class
View Answer
Answer: B
In C++ object oriented programming, abstract class is used for the same, in which we have
common or say generalized function in abstract base class and also may have pure virtual
function in this class that forces derived classes to implement it.
Read in detail about abstract class oops concepts with example in C++ and pure virtual
function used to create abstract class and interface in C++ language
Q) Not using virtual destructor feature in a C++ object oriented programing can cause
A. Memory leak
B. An Issue in creating object of the class
C. An issue in calling base class destructor
D. Nothing
View Answer
Answer: A
Virtual destructor is used to maintain the hierarchy of destructor calls for polymorphic classes in
inheritance. If we don’t use it then it may cause resource leak or memory leak. Read the all
concept of C++ virtual destructor. Know if it is necessary to write virtual destructor or when to
write etc.
A. Encapsulation
B. Inheritance
C. Abstraction
D. None
View Answer
Answer: A
Inheritance feature is used for concept of code re-usability as in inheritance a class can inherit
properties and functions of existing well written class.
Abstraction : Provide only necessary information to client code.
Encapsulation: Hide complexity. e.g. by wrapping private class data members by functions. By making
internal function of a class private and using interfaces etc.
A. Inheritance
B. Polymorphism
C. encapsulation
D. None
Answer : A
Explanation: Base class and derived class come under inheritance, one of the C++ oops
principle. Also, it is known as parent child relationship.
Q) C++ Inheritance relationship is
A. Association
B. Is-A
C. Has-A
D. None
Answer:B
A. Multilevel
B. Multiple
C. Hierarchical
D. All the above
Answer: D
A. Class Re-usability
B. Creating a hierarchy of classes
C. Extendibility
D. All
Answer: D
Explanation: Advantage of inheritance are like re-usability- You can re-use existing class in a
new class that avoid re-writing same code and efforts.
We can make an application easily extensible.
A. Constructor
B. Destructor
C. Static function
D. None
Answer:D
Explanation:
In C++, constructor and destruction of a class cannot be inherited to derived class. However,
when we create the object of derived class then constructor of the base class is called
automatically. You can read order of execution of constructors and destructors call in c++
inheritance.
Static function is not the part of an object, Hence, it cannot be inherited in derived classes. Note
that all the class member functions that are the part of an object, only they can be inherited. Read
what is static function in C++ programming
A. Private
B. Protected
C. Public
D. None
Answer:A
Q) Accessing functions from multiple classes to a derived class is known as
A. multiple inheritance
B. single inheritance
C. Hybrid inheritance
D. multilevel inheritance
Answer:A
Q) In inheritance, order of execution of base class and derived class destructors are
A. Base to derived
B. Derived to base
C. Random order
D. none
Answer: B
In inheritance, execution order of constructors are always from base to derived and destructors
call order is in reverse i.e. from derived to base. In polymorphic classes, means the class that
contain virtual functions, we need to make destructor virtual in base class. Other wise the derived
class destructor will not be called. Read detail about C++ virtual destructor with example.
A. Operator overloading
B. Function overloading
C. Function overriding
D. B Only
E. A&B
View Answer
Answer: E
Q) C++ abstract class can contain
View Answer
Answer: D
A. Defining multiple functions with same name in a class is called function overloading
B. Overloaded function must differ in their order and types of arguments.
C. Overloaded functions should be preceded with virtual keyword
D. No statement is false
View Answer
Answer: C
Q) Following keyword is used before a function in a base class to be overridden in derived class in
C++
A. override
B. virtual
C. void
D. none
View Answer
Answer: B
A. Increment operator
B. Constructor
C. Destructor
D. New and delete operator
View Answer
Answer: C
Destructor of a class cannot be overloaded in C++ programming. Increment operator, constructor
and new and delete can be overloaded.
View Answer
Answer: B
You can read in detail about pure virtual function in C++ and how we use pure virtual
function to create an interface in C++ program.
A. To create an interface
B. To make a class abstract
C. To force derived class to implement the pure virtual function
D. All the above
View Answer
Answer: D
All are correct. Recommended to read abstract class in C++ with example that uses pure
virtual function.
A. Constructor
B. Destructor
C. Both A & B
D. Only B
View Answer
Answer: C
A. 0
B. 1
C. 2
D. 3
View Answer
Answer: B
A. 0
B. 1
C. 2
D. 3
View Answer
Answer: C
View Answer
Answer: B
C++ does not have keyword interface like C# or java. Pure virtual function is used to create
an interface in C++ programs.
View Answer
Answer: D
View Answer
Answer: D
A. Function overriding
B. Operator overloading
C. A&B
D. None
View Answer
Answer: A
A. Constructor
B. Class destructor
C. Both a & b
D. None
View Answer
Answer: B
Destructor of a class cannot be overloaded. Read in detail in the interview question can we
overload destructor in C++ program?
Q) Operators can be overloaded in C++ is/are
A. New
B. Delete
C. ++
D. All can be overloaded
View Answer
Answer: D
A. Pass by value
B. Pass by reference
C. Pass by pointer
D. All the above
View Answer
Answer: D
In C++ programming, all pass by value, reference and pointer are used. Note that pass by reference in C
Programming language is not available. However, sometimes people use the term pass by reference
instead of pass by address or pass by pointers. Read here pass by value and pass by pointer in C
programming and difference between pass by pointer and pass by reference in C++ language.
A. void display()
B. void display() const
C. const void display()
D. void const display()
View Answer
Answer: B
Constant function in a class is used to prevent modification of class member variables inside its
body. When we only want to read member variable and use it in function body with no
modification then we should use const function. Read detail of constant function in C++ object
oriented programming.
Q) True and false statements about inline function in given C++ code example is/are
(I)Static function of a class can be called by class name using scope resolution operator i.e. : :
(II)Static function can receive both static and non-static data members of a class
(III)Static function is not the part of an object of a class
A. I and II
B. I only
C. I and III
D. I, II and III
View Answer
Answer: C
Read in detail about static function in C++ with example and if static function can access
non static data in C++ program.
Q) Which of the following functions are provided by compiler by default if we don’t write in a C++
class?
A. Copy constructor
B. Assignment
C. Constructor
D. All the above
View Answer
Answer: D
A. Static function
B. Inline function
C. Friend function
D. constant function
View Answer
Answer: A
Q) True and false about inline function statements in C++
class A{
public:
void func1(){
}
void func2();
};
inline void A::func2(){
View Answer
Answer: C
A. Virtual function
B. Inline function
C. Static function
D. constant function
View Answer
Answer: C
View Answer
Answer: A
Explanation:Default arguments in a function in C++ program is initialized from right to left.
Q) Which function cannot be overloaded in C++ program?
A. Virtual function
B. member function
C. Static function
D. All can be overloaded
View Answer
Answer: C
Static functions cannot be overloaded in C++ programming. You can read static function in C++ and how
it differs from C.
Q) Choose the correct answer for following piece of C++ pseudo code
void func(int a, int &b)
{
int main(){
int a,b;
func(a,b);
}
View Answer
Answer: A
B parameter is not pass by address/pointer but reference. Here is the correct pseudo code for pass by
address or say pointer.
int main(){
int a,b;
func(a,&b);
}
Read about difference between pointer and reference in C++
View Answer
Answer: C
Function overloading is compile time polymorphism in which 2 or more functions share the same name
with different arguments and parameters in C++ oops.
Recommended to read function overloading in C++
NOTE: In C++, constructor is also a special type of function that can be overloaded. You can
read advantage of constructor overloading in C++ applications.
View Answer
Answer: A
A is the correct declaration of pure virtual function in a class in C++.