Object Oriented System Design Questions and Answers – Programming Principles

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

Answer: a
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

Answer: d
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

Answer: a
Explanation: ‘Encapsulation’ acts as protective wrapper that prevents code and data from being accessed by other code defined outside the wrapper.
advertisement
advertisement

4. What is ‘Basis of Encapsulation’?
a) object
b) class
c) method
d) all of the mentioned
View Answer

Answer: d
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

Answer: a
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?

  1.  class Test {
  2.      int a;
  3.      public int b;
  4.      private int c;
  5.  }
  6.  class AcessTest {
  7.      public static void main(String args[])
  8.      {
  9.          Test ob = new Test();
  10.          ob.a = 10;
  11.          ob.b = 20;
  12.          ob.c = 30;
  13.          System.out.println(" Output :a, b, and c" + ob.a + " " + ob.b + " " + ob.c);
  14.      }
  15. }

a) Compilation error
b) Run time error
c) Output : a, b and c 10 20 30
d) None of the mentioned
View Answer

Answer: a
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.
advertisement

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

Answer: c
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.
advertisement

8. Which of the following supports the concept of hierarchical classification?
a) Polymorphism
b) Encapsulation
c) Abstraction
d) Inheritance
View Answer

Answer: d
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

Answer: a
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

Answer: b
Explanation: None.

Sanfoundry Global Education & Learning Series – Object Oriented System Design.

Here’s the list of Best Books in Object Oriented System Design.

To practice all areas of Objection Oriented System Design, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.