This set of Object Oriented System Design Multiple Choice Questions & Answers (MCQs) focuses on “Object Oriented Programming Principles”.
1. Which of the following is the functionality of ‘Data Abstraction’?
a) Reduce Complexity
b) Binds together code and data
c) Parallelism
d) None of the mentioned
View Answer
Explanation: An essential element of Object Oriented Programming is ‘Data Abstraction’ which means hiding things. Complexity is managed through abstraction.
2. Which of the following mechanisms is/are provided by Object Oriented Language to implement Object Oriented Model?
a) Encapsulation
b) Inheritance
c) Polymorphism
d) All of the mentioned
View Answer
Explanation: None.
3. Which of the these is the functionality of ‘Encapsulation’?
a) Binds together code and data
b) Using single interface for general class of actions.
c) Reduce Complexity
d) All of the mentioned
View Answer
Explanation: ‘Encapsulation’ acts as protective wrapper that prevents code and data from being accessed by other code defined outside the wrapper.
4. What is ‘Basis of Encapsulation’?
a) object
b) class
c) method
d) all of the mentioned
View Answer
Explanation: Encapsulation is the mechanism that binds together code and data it manipulates, and keeps both safe from outside interface and misuse. Class, which contains data members and methods is used to implement Encapsulation.
5. How will a class protect the code inside it?
a) Using Access specifiers
b) Abstraction
c) Use of Inheritance
d) All of the mentioned
View Answer
Explanation: Each method or variable in a class may be marked ‘public’ or ‘private’. They are called Access Specifiers.
6. What is the output of this program?
class Test {
int a;
public int b;
private int c;
}
class AcessTest {
public static void main(String args[])
{
Test ob = new Test();
ob.a = 10;
ob.b = 20;
ob.c = 30;
System.out.println(" Output :a, b, and c" + ob.a + " " + ob.b + " " + ob.c);
}
}
a) Compilation error
b) Run time error
c) Output : a, b and c 10 20 30
d) None of the mentioned
View Answer
Explanation: Private members of a class cannot be accessed directly. In the above program, the variable c is a private member of class ‘Test’ and can only be accessed through its methods.
7. Which of the following is a mechanism by which object acquires the properties of another object?
a) Encapsulation
b) Abstraction
c) Inheritance
d) Polymorphism
View Answer
Explanation: ‘Inheritance’ is the mechanism provided by Object Oriented Language, which helps an object to acquire the properties of another object usually child object from parent object.
8. Which of the following supports the concept of hierarchical classification?
a) Polymorphism
b) Encapsulation
c) Abstraction
d) Inheritance
View Answer
Explanation: Use of Hierarchical classification avoids defining the properities of object explicitly at each level which have acquired their properties from higher levels.
9. Which Keyword from the following is used to inherit properties from one class into another?
a) extends
b) subclasses
c) native
d) all of the mentioned
View Answer
Explanation: None.
10. Which of the following concept is often expressed by the phrase, ‘One interface, multiple methods’?
a) Abstraction
b) Polymorphism
c) Inheritance
d) Encapsulation
View Answer
Explanation: None.
Sanfoundry Global Education & Learning Series – Object Oriented System Design.
Here’s the list of Best Books in Object Oriented System Design.
If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]