C++ QB
C++ QB
1. What is ‘encapsulation’?
a. It is a collection of similar data items,
b. It is a combination of similar data items and the function
c. It is the combination of data items and function
d. It is the division of a program into independent module
2. Abstraction is?
a. A collection of similar data items
b. A combination of similar data items and the function
c. The combination of data items and function
d. A collection of necessary data items and function
3. Encapsulation is used?
a. To hide the information
b. for data abstraction
c. to define all necessary features of the real-world objects
d. all of the above
11. Encapsulation is an
a. abstraction of structure
b. abstraction of class
c. abstraction of privilege
d. abstraction of object
12. Class is a collection of
a. similar objects
b. similar function
c. dissimilar objects
d. dissimilar function
14. Which of the following supports the capability of one class to use
properties of another class?
a. Class
b. Inheritance
c. polymorphism
d. Encapsulation
16. Which of the following language makes the software reuse possible?
a. object-oriented programming
b. object-based programming
c. procedure-oriented programming
d. Structure-oriented programming
27. A class?
a. Is a user-defined data type
b. is a metadata
c. is a technique to implement encapsulation
d. All the above
33. Which of the following notation is used to draw the object diagram?
a. circle
b. triangle
c. Square box
d. Rectangle box
34. Where would you place the class name on the diagram/
a. outside the diagram
b. Top
c. Bottom
d. Middle
35. The first parent class is also called as
a. ancestor class
b. base class
c. super class
d. all the above
Review Question.
a. Encapsulation
b. Data abstraction
c. Inheritance
d. Polymorphism
e. Class and Objects
f. Multiple inheritance
6. iostream.h is a
a. Header file
b. Preprocessor directives
c. User-defined function
d. Both (a) and (b)
7. cout in C++ is a
a. Object
b. Class
c. Function
d. Command
9. << is called
a. insertion operator
b. Extraction operator
c. Object
d. Function
10.>> is called
a. insertion operator
b. Extraction operator
c. Object
d. Function
11.In the statement if (1/2) {cout<<”hello”;} else {cout<<”hi”;}
a. There is an error
b. It will display message hello
c. It will display message hi
d. Infinite loop
18.The for ( int i=0;I < 5: i++); cout<<i<<” “; will give the output
a. An error
b. 0 1 2 3 4
c. 5
d. Infinite loop
19.The for (int i=0, int j = 0; i<5: i++) cout <<i<<” “<<j; will give the
output
a. an error
b. 0 0 1 0 2 0 3 0 4 0
c. 5
d. Infinite loop
Review Question
LESSON-3, FUNCTIONS.
9. which storage specifier retains the value between the function call
a. auto
b. register
c. extern
d. static
12.if function does not return any value then its return type is
a. int
b. float
c. void
d. char
Review Questions
1. Arrays is a collection of
a. integer data item
b. similar data items
c. dissimilar data items
d. built-in data type
2. Array is a
a. derived data type
b. built-in data type
c. enumerated data type
d. user-defined data type
REVIEW QUESTIONS
2. struct is
a. an identifier
b. constant
c. keyword
d. user-defined variable
4. Structure is a collection of
a. similar data items
b. dissimilar data items
c. it may be similar or dissimilar data items
d. special characters
6. A = B is valid if
a. A and B are variables of the same structure type
b. A and B are variables of the different structure type
c. Both (a) and (b) are true
d. Error
7. Structure tag is a
a. an identifier
b. structure variable
c. structure name
d. keyword
9. while accessing the structure members, left side of dot operator must
be
a. Structure variable
b. Structure pointer
c. Keyword struct
d. Index value
10.What will be output of the following?
struct sample
{
Unsigned int rollno: 12;
Char name {2}: 16;
Unsigned int age : 12;
} X;
Cout<<X.rollno. <<X.
Name<<X.age;
a. Bit field must have integral type
b. 12 16 12
c. Bit field is too large
d. Nothing
Review Question
LESSON-6, POINTERS.
Review Questions
1. What is a pointer?
2. What is the relationship between array and a pointer?
3. What is the difference between & and * operator?
4. What are the operations possible with pointer variables?
5. How is an array and a pointer related?
6. What do understand by pointer to pointer?
7. Explain pointer to function?
8. What are the differences between array of pointers and pointer
to the array?
9. What are the differences between array of pointers and pointer
to pointer?
10.What are the difference between malloc () and new operators?
11.What are the differences between free () and delete?
LESSON-7, CLASSES AND OBJECTS.
3. Class is a
a. built-in data type
b. user-defined data type
c. derived data type
d. enumerated data type
4. Class is
a. collection of similar elements
b. collection of dissimilar elements
c. combination of data members and member functions
d. none of the above
24.Can two classes contain member functions with the samr name?
a. no
b. yes, but if both the class have the same name
c. if it a friend function
d. Yes, this is always allowed
25.A class is a
a. data type
b. user-defined type
c. abstract type
d. all the above
REVIEW QUESTIONS
2. If three objects Z,X and Y are created from the same class then
the sequence of constructor calling for the objects?
a. Z X Y
b. X Y Z
c. Y Z X
d. In any order
3. If three objects Z, X and Y are from the same calss then the
sequences of destructor invocation is
a. Z X Y
b. X Y Z
c. Y X Z
d. In any order
4. constructor is
a. A function which is automatically called when object is created
b. It is called explicitly when object is created
c. A function which destroys the objects
d. A special operator like new or delete
12. Destructor is
a. A function which is automatically called when object is created
b. It is called explicitly when object is created
c. A function which destroys the object
d. A special operator like new or delete
REVIEW QUESTION
13.If a base class and a derived class contain the member function with
the same name then the function that will be called by the object of
the derived class is
a. Base class
b. Derived class
c. Depend on the virtual base class
16.Deriving multiple classes from single base class and then deriving a
class from these multiple base classes is called?
a. Multilevel inheritance
b. Multiple inheritances
c. Hybrid inheritance
d. None of the above
17.In the derived class member functions can access the following base
class members in inheritance
a. Public and protected only
b. Private and protected only
c. Private and public only
d. Private, public and protected
18.An object of the derived class can access the following base class
members in inheritance?
a. Public and protected only
b. Public only
c. Protected only
None
21.if class B, class C:A{}; is written in C++ then the type of inheritance
is
a. Multiple inheritance
b. Hierarchical inheritance
c. Multilevel inheritance
d. none of the above
22.Inheritance is used to
a. Avoid rewriting of the code
b. Data abstraction
c. To change the visibility modes
d. To use virtual base class
26.The relationship between the base class and the derived class is called
a. “Is-A” relationship
b. “Kind-Of” relationship
c. “Part-Of” relationship
d. Both (a) and (b)
27.If class B: class A, class C {}; is written in C++ then the type of
inheritance is
a. Multiple inheritance
b. Hierarchical inheritance
c. Multilevel inheritance
d. None of the above
28.If class B: class A, class C {}; is written in C++ then the visibility
mode in multiple inheritance is
a. Private
b. Public
c. Protected
d. All
REVIEW QUESTIONS
1. What is reusability?
2. Explain the virtual base class?
3. In what order are the constructors called when a derived class object is
created?
4. What is the difference between a container class and nested class/
5. What is the difference between the private mode inheritance and the
protected mode inheritance?
6. How do we make a class virtual?
7. When do we make a class virtual?
8. Describe the hybrid inheritance?
9. How is the ambiguity removed in single-level inheritance?
10.What are the visibility modes?
11.Explain how a protected member of a base class can be accessed by
the public member function of the derived class?
12.What are the advantages of inheritance?
13.How does the containership differ from inheritance?
14.How does the visibility mode control the access of members in the
derived class?
15.What is the significance of virtual base class?
16.Explain the different forms of inheritance with the help of suitable
example?
17.What are public inheritance, private inheritance and protected
inheritance?
LESSON-10, POLYMORPHISM.
2. How many operators overloading can be defined for the same operator
in as single class?
a. 1
b. 2
c. 3
d. No limit
9. Operator overloading is
a. A Class
b. A concept by which we can give special meaning to an operator of
language
c. An object of a language
d. A concept by which we can design new object
19.How does the compiler decide which over loaded function to call?
a. It calls all the function having same name
b. It calls the function with the closest signature
c. It calls only those function with the return type void
d. It calls the first function it finish with the same name
25.To overload the > operator as a friend function, how many parameters
are required?
a. Ternary operator cannot be overloaded at all
b. 1
c. 2
d. 1 or 2
28.Pointer to base class can access the members (same name) of the
derived class only, if
a. Pointer holds the address of the derived class’s object and function in
the base class are defined as virtual
b. Pointer holds the address of the base class’s object and functions in
the base class are defined as virtual
c. Pointer holds the address of the derived class’s object and function in
the derived class are defined as virtual
d. Pointer hold the address of the base class’s object and functions in the
derived class are defined as virtual
REVIEW QUESTIONS
1. What is polymorphism? List the advantages and disadvantages of
using polymorphism on object-oriented programming?
2. What are static and dynamic binding?
3. How the operator overloading is done by using friend function?
Explain with example?
4. Explain how polymorphism is implemented using keyword virtual?
5. What is pure virtual function? What are the advantages and
disadvantages of defining and declaring a pure virtual function in
object-oriented programming?
6. What is the abstract base class and what are the advantages of using it
in a programming?
7. What is function overloading? What are the scope rules for governing
the function overloading?
8. Explain why a constructor member function cannot be a virtual
method?
9. Explain the various techniques of defining a pure virtual function?
10.How is function overloading done with default arguments? What is
the major limitation of default arguments?
5. A template is
a. a collection of similar elements
b. a collection of dissimilar elements
c. a combination of data members and member function
d. none of the above
REVIEW QUESTIONS
1. What is a template?
2. What are the advantages and disadvantages of templates?
3. What is function template?
4. Do you agree with the statement that “a template increases the
efficiency of designing a program”?
If yes, explain?
5. How is the function template defined in a program in C++? What are
the rules that must be followed to define a function template?
6. What is a class template? What are the rules that must be followed to
define a class template?
7. What is the difference between an overloaded function and a function
template?
8. What is the difference between a class template and a template class?
9. What is generic programming and how is it implemented in C++?
10.How does the template support polymorphism?
11.What is an exception?
12.What may be the conditions when an exception occurs?
13.Explain try, catch throw?
14.Where are the keywords try, catch and throw used?
15.What are the advantages of using exception handling mechanism in a
program?
16. What happens if several handlers match the type of thrown object?
17.Explain how an exception handler is defined and invoked in a
program?
18.Can we restrict the exception type?
1. In a binary file?
a. No character translation take place
b. Only new line character is translated
c. None of the above
4. Which mode is used to seek the end of file upon opening the file
a. ios: : in
b. ios: :out
c. ios: :ate
d. ios: :app
7. Which of the following are used to read and write block of data?
a. read () and write ()
b. get () and put ()
c. getline () and cout
d. none of the above
10.cin is
a. an object of istream class
b. an object of ostream class
c. an operator, not an object
d. None of the above
14. Which operator is used to send the data to output file to output to an
output file?
a. >>
b. <<
c. ? :
d. None of the above
REVIEW QUESTIONS
6. To position the cursor within the text window you would use
a. gotoxy ()
b. setcursor ()
c. moveto ()
d. putch ()
7. Graphics mode functions are included in
a. iostream.h
b. conio.h
c. graphics.h
d. stdlib.h
9. Which of the following is used for setting the window size for
graphics output?
a. setviewport ()
b. graphdefault ()
c. window ()
d. None of the above
15.fillpoly () is used to
a. draw a polygon
b. draw and fill s polygon
c. draw an ellipse
d. draw an arc
REVIEW QUESTION
3. cin is
a. a command
b. an object
c. variable
d. none of the above
REVIEW QUESTIONS