Solved 100+ MCQs Object-oriented Programming
Solved 100+ MCQs Object-oriented Programming:
--------------------------------------------------------------------------------------------- What will be the output of following program? #include<iostream.h> void main() { float x; x=(float)9/2; cout<<x; } | ||||||||
The term __________ means the ability to take many forms.
| ||||||||
Runtime polymorphism is achieved by
| ||||||||
Access to private data
| ||||||||
Additional information sent when an exception is thrown may be placed in
| ||||||||
A static data member is given a value
| ||||||||
_____________________________________________________________________________________ | ||||||||
In a class specifier ,data or function designated private are accessible
| ||||||||
Which of the statements are true ? I. Function overloading is done at compile time. II. Protected members are accessible to the member of derived class. III. A derived class inherits constructors and destructors. IV. A friend function can be called like a normal function. V. Nested class is a derived class.
| ||||||||
At which point of time a variable comes into existence in memory is determined by its
| ||||||||
When the compiler cannot differentiate between two overloaded constructors, they are called
| ||||||||
The actual source code for implementing a template function is created when
| ||||||||
Usually a pure virtual function
| ||||||||
Which of the following is the valid class declaration header for the derived class d with base classes b1 and b2?
| ||||||||
The process of extracting the relevant attributes of an object is known as
| ||||||||
What features make C++ so powerful ?
| ||||||||
Which of the following operator can be overloaded through friend function?
| ||||||||
The keyword friend does not appear in
| ||||||||
Exception handling is targeted at
| ||||||||
Function templates can accept
| ||||||||
If the variable count exceeds 100, a single statement that prints “Too many” is
| ||||||||
The mechanism that binds code and data together and keeps them secure from outside world is known as
| ||||||||
The operator << when overloaded in a class
| ||||||||
To access the public function fbase() in the base class, a statement in a derived class function fder() uses the statement.fbase();
| ||||||||
In which case is it mandatory to provide a destructor in a class?
| ||||||||
_________ members of a base class are never accessible to a derived class.
| ||||||||
What is the error in the following code? class t { virtual void print(); }
| ||||||||
It is possible to declare as a friend
| ||||||||
A struct is the same as a class except that
| ||||||||
C++ was originally developed by
| ||||||||
What is the output of the following code char symbol[3]={‘a’,‘b’,‘c’}; for (int index=0; index<3; index++) cout << symbol [index];
| ||||||||
If we create a file by ‘ifstream’, then the default mode of the file is _________
| ||||||||
The following can be declared as friend in a class
| ||||||||
The polymorphism can be characterized by the phrase
| ||||||||
A virtual class is the same as
| ||||||||
Member functions, when defined within the class specification
| ||||||||
Assume that we have constructor functions for both base class and derived class. Now consider the declaration in main( ). Base * P = New Derived; in what sequence will the constructor be called ?
| ||||||||
The operator that cannot be overloaded is
| ||||||||
Which of the following declarations are illegal?
| ||||||||
Identify the operator that is NOT used with pointers
| ||||||||
Which of the following statements is NOT valid about operator overloading?
| ||||||||
Overloading a postfix increment operator by means of a member function takes
| ||||||||
Which of the following will produce a value 10 if x = 9.7?
| ||||||||
Which of the following is not the characteristic of constructor?
| ||||||||
You may override the class access specifiers
| ||||||||
You separated a derived class name from its access specifier with
| ||||||||
Consider the following statements: int x = 22,y=15; x = (x>y) ? (x+y) : (x-y); What will be the value of x after executing these statements?
| ||||||||
A friend function to a class, C cannot access
| ||||||||
The members of a class by default are
| ||||||||
If x =5, y =2 then x ^y equals________. (where ^ is a bitwise XOR operator)
|
1. UNIT – 1 (OOP Concepts and Introduction to C++)
1 In structured programming, the problem is divided into various ______.(A) modules (B) functions
(C) structures (D) objects
2 In Object-oriented programming, the problem is divided into _____.
(A) classes & objects (B) functions
(C) structures (D) modules
3 A class is ____ datatype.
(A) primitive (B) derived
(C) user-defined (D) All of these
4 A class is a collection of ____ and _____.
(A) data-members & member functions (B) data-members, member functions and
main()
(C) data-members, member functions,
main() and include statements
(D) None of these
5 An object is ……
(A) a variable of class datatype. (B) same as a class.
(C) just like a global variable. (D) collection of data-members and
member functions.
6 Wrapping up of data & functions together in a class is known as _____.
(A) Overloading (B) Data Abstraction
(C) Polymorphism (D) Encapsulation
7 Including only necessary details and ignoring additional details while defining a class is
known as ____.
(A) Overloading (B) Data Abstraction
(C) Polymorphism (D) Encapsulation
8 Preventing direct access of data-members of the class from outside world is known as ____.
(A) Polymorphism (B) Encapsulation
(C) Data Hiding. (D) scope resolution.
9 What are cin and cout?
(A) pointers (B) functions
(C) operator (D) stream objects
10 Which header file must be included for cin and cout?
(A) stdio.h (B) conio.h
(C) iostream.h (D) Both iostream.h and conio.h
11Creating a new class using one or more existing classes is known as ____.
(A) Polymorphism (B) Encapsulation
(C) overloading (D) inheritance
12Ability of an operator or function call to take different forms is known as ____.
(A) Polymorphism (B) Encapsulation
(C) overloading (D) inheritance
Answers 1 – B 2 – A 3 – C 4 – A 5 – A 6 – D
7 – B 8 – C 9 – C 10 – C 11 – D 12 - A
UNIT – 2 (Control Flow Constructs, Input /Output and Arrays)
1 Which of the following can replace a simple if-else construct?
(A) Ternary operator (B) while loop
(C) do-while loop (D) for loop
2 Which of the following is an entry-controlled loop?
(A) do-while loop (B) while loop
(C) for loop (D) Both (B) and (C)
3 Which of the following is most suitable for a menu-driven program?
(A) do-while loop (B) while loop
(C) for loop (D) All of these
4 Consider the following loop : for(int i=0; i<5; i++) ;
What will be the value of i after this loop?
(A) It will give compilation error. (B) 5
(C) 6 (D) Some Garbage value
5 A switch construct can be used with which of the following types of variable?
(A) int (B) int, char
(C) int, float, char (D) Any basic datatype
6 Which of the following must be present in switch construct?
(A) Expression in ( ) after switch (B) default
(C) case followed by value (D) All of these
7 What is the effect of writing a break statement inside a loop?
(A) It cancels remaining iterations. (B) It skips a particular iteration.
(C) The program terminates immediately. (D) Loop counter is reset.
8 What is the effect of writing a continue statement inside a loop?
(A) It cancels remaining iterations. (B) It skips execution of statements which
are written below it.
(C) The program terminates immediately. (D) Loop counter is reset.
9 What are cin and cout?
(A) pointers (B) functions
(C) operator (D) stream objects
10 Which header file must be included for cin and cout?
(A) stdio.h (B) conio.h
(C) iostream.h (D) Both iostream.h and conio.h
11 Which of the following is NOT correct 1D array declaration?
(A) int a[ ] = {1 , 2 , 3} ; (B) int a[5] = {1 , 2 , 3} ;
(C) int a[5] = {0} ; (D) int a[3] = {1 , 2 , 3, 4 , 5} ;
12 Which of the following is NOT correct 2D array declaration?
(A) int m[ ] [3] = {1 , 2 , 3, 4} ; (B) int m[3][ ] = {1 , 2 , 3, 4} ;
(C) int m[2][3]; (D) int m[R] [C]; (R & C are constants)
Answers
1 – A 2 – D 3 – A 4 – B 5 – B 6 – A
7 – A 8 – D 9 – C 10 – C 11 – D 12 - B
Comments
Post a Comment