OBJECT ORIENTED PROGRAMMING MCQ's SET-2
1. Instance of which type of class can’t be created?
a) Anonymous class
b) Nested class
c) Parent class
d) Abstract class
Answer: d
2. Which definition best describes an object?
a) Instance of a class
b) Instance of itself
c) Child of a class
d) Overview of a class
Answer: a
3. How many objects can be declared of a specific class in a single program?
a) 32768
b) 127
c) 1
d) As many as you want
Answer: d
4. Which among the following is false?
a) Object must be created before using members of a class
b) Memory for an object is allocated only after its constructor is called
c) Objects can’t be passed by reference
d) Objects size depends on its class data members
Answer: c
5. Which of the following is incorrect?
a) class student{ }s;
b) class student{ }; student s;
c) class student{ }s[];
d) class student{ }; student s[5];
Answer: c
6.The object can’t be __________
a) Passed by reference
b) Passed by value
c) Passed by copy
d) Passed as function
Answer: d
7. Functions can’t return objects.
a) True
b) False
Answer: b
8. How members of an object are accessed?
a) Using dot operator/period symbol
b) Using scope resolution operator
c) Using member names directly
d) Using pointer only
Answer: a
9. If a local class is defined in a function, which of the following is true for an object of that class?
a) Object is accessible outside the function
b) Object can be declared inside any other function
c) Object can be used to call other class members
d) Object can be used/accessed/declared locally in that function
Answer: d
10. Which among the following is wrong?
a) class student{ }; student s;
b) abstract class student{ }; student s;
c) abstract class student{ }s[50000000];
d) abstract class student{ }; class toppers: public student{ }; topper t;
Answer: b
11. Object declared in main() function _____________
a) Can be used by any other function
b) Can be used by main() function of any other program
c) Can’t be used by any other function
d) Can be accessed using scope resolution operator
Answer: c
12. When an object is returned___________
a) A temporary object is created to return the value
b) The same object used in function is used to return the value
c) The Object can be returned without creation of temporary object
d) Object are returned implicitly, we can’t say how it happens inside program
Answer: a
13. Which among the following is correct?
a) class student{ }s1,s2; s1.student()=s2.student();
b) class student{ }s1; class topper{ }t1; s1=t1;
c) class student{ }s1,s2; s1=s2;
d) class student{ }s1; class topper{ }t1; s1.student()=s2.topper();
Answer: c
14. Object can’t be used with pointers because they belong to user defined class, and compiler can’t decide the type of data may be used inside the class.
a) True
b) False
Answer: b
15. Which feature of OOP indicates code reusability?
a) Encapsulation
b) Inheritance
c) Abstraction
d) Polymorphism
Answer: b
16. If a function can perform more than 1 type of tasks, where the function name remains same, which feature of OOP is used here?
a) Encapsulation
b) Inheritance
c) Polymorphism
d) Abstraction
Answer: c
17. If different properties and functions of a real world entity is grouped or embedded into a single element, what is it called in OOP language?
a) Inheritance
b) Polymorphism
c) Abstraction
d) Encapsulation
Answer: d
18. Which of the following is not a feature of pure OOP?
a) Classes must be used
b) Inheritance
c) Data may/may not be declared using object
d) Functions Overloading
Answer: c
19. Which among the following doesn’t come under OOP concept?
a) Platform independent
b) Data binding
c) Message passing
d) Data hiding
Answer: a
20. Which feature of OOP is indicated by the following code?
class student{ int marks; };
class topper:public student{ int age; topper(int age){ this.age=age; } };
a) Inheritance
b) Polymorphism
c) Inheritance and polymorphism
d) Encapsulation and Inheritance
Answer: d