Object Oriented System Design Questions and Answers – Object Oriented Programming

This set of Object Oriented System Design Multiple Choice Questions & Answers (MCQs) focuses on “Object Oriented Programming”.

1. Which of the following approach help us understand better about Real time examples, say Vehicle or Employee of an Organisation?
a) Procedural approach
b) Object Oriented approach
c) Both a and b
d) None of the mentioned
View Answer

Answer: b
Explanation: Object Oriented Programming supports the concept of class and object which help us understand the real time examples better. Vehicle is defined to be a class. Car, truck, bike are defined to be objects of the class, Vehicle.

2. Which of the following Paradigm is followed by Object Oriented Language Design?
a) Process-Oriented Model
b) Data Controlling access to code.
c) Both a and b
d) None of the mentioned
View Answer

Answer: b
Explanation: Object-oriented programming organises a program around its data(that is, objects) and a set of well-defined interfaces to that data.

3. Which of the following approach is followed by Object Oriented Language during the execution of a program?
a) Bottom up approach
b) Top down approach
c) Both a and b
d) None of the mentioned
View Answer

Answer: a
Explanation: Bottom up approach begins with details and moves to higher conceptual level there by reducing complexity and making the concept easier to understand.
advertisement
advertisement

4. Which of the following is/are advantage of using object oriented programming?
a) Code Reusability
b) Can create more than one instance of a class without interference
c) Platform independent
d) All of the mentioned
View Answer

Answer: d
Explanation: None.

5. Java Compiler translates the source code into?
a) Machine code
b) Assembly code
c) Byte code
d) JVM code
View Answer

Answer: c
Explanation: Java program is converted into ‘byte code’ which makes it easier to run on wide variety of environments. Only the run-time package JVM has to be implemented for each platform.

6. What is the output of this program?

  1. class PrintTest {
  2.     public static void main(String args[])
  3.     {
  4.         int num = 10;
  5.         if (NUM < 100) {
  6.             System.out.println("The value of num is"+ num);
  7.         }
  8.     }
  9. }

a) Compilation error
b) Run time error
c) The value of num is 10
d) None of the mentioned
View Answer

Answer: a
Explanation: Java is case-sensitive. The variable ‘num’ used in print statement is not same as the variable ‘NUM’ used in the if conditional statement.
advertisement

7. Which of the following is called as ‘Comiplation unit’?
a) Object file
b) Byte code
c) Source file
d) All of the mentioned
View Answer

Answer: c
Explanation: None.
advertisement

8. What is the output of this program?

  1. class TypeChecking {
  2.     public static void main(String args[]) 
  3.     {
  4.         int num = 10.5;
  5.         System.out.println("Output :The value of num is" +num);
  6.     }
  7. }

a) Output: The value of num is 10.5
b) Run-time error
c) Compilation error
d) None of the mentioned
View Answer

Answer: c
Explanation: Java is storngly typed language. The variable num is declared as ‘int’ but the value assigned to it is ‘float’, as a result the code does not get compiled.

9. Which is a named memory location assigned a value by the program?
a) variable
b) literal
c) identifier
d) None of the mentioned
View Answer

Answer: a
Explanation: None.

10. What is the output of this program?

  1.  class A {
  2.      int i, j;
  3.      void showij() {
  4.          System.out.println("i and j:" + i +" "+j);
  5.      }
  6.  }
  7.  class B extends A
  8.  {
  9.      int k;
  10.      void showk()
  11.      {
  12.          System.out.println("k: "+ k);
  13.      }
  14.      void sum() {
  15.          System.out.println("i + j + k:" + (i + j + k));
  16.      }
  17.  }  
  18.  class SimpleInheritance {
  19.      public static void main(String args[]) 
  20.      {     
  21.          B subob = new B();
  22.          subob.i = 5;
  23.          subob.j = 6;
  24.          subob.k = 9;
  25.          System.out.println("The contents are");
  26.          subob.showk();
  27.          subob.sum();
  28.       }
  29.  }

a) Run-time error
b) Compilation error
c) Output: The contents are k: 9
d) None of the mentioned
View Answer

Answer: c
Explanation: class B inherits from class A and can access the variables i and j through class A.

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.