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
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
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
Explanation: Bottom up approach begins with details and moves to higher conceptual level there by reducing complexity and making the concept easier to understand.
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
Explanation: None.
5. Java Compiler translates the source code into?
a) Machine code
b) Assembly code
c) Byte code
d) JVM code
View Answer
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?
class PrintTest {
public static void main(String args[])
{
int num = 10;
if (NUM < 100) {
System.out.println("The value of num is"+ num);
}
}
}
a) Compilation error
b) Run time error
c) The value of num is 10
d) None of the mentioned
View Answer
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.
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
Explanation: None.
8. What is the output of this program?
class TypeChecking {
public static void main(String args[])
{
int num = 10.5;
System.out.println("Output :The value of num is" +num);
}
}
a) Output: The value of num is 10.5
b) Run-time error
c) Compilation error
d) None of the mentioned
View Answer
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
Explanation: None.
10. What is the output of this program?
class A {
int i, j;
void showij() {
System.out.println("i and j:" + i +" "+j);
}
}
class B extends A
{
int k;
void showk()
{
System.out.println("k: "+ k);
}
void sum() {
System.out.println("i + j + k:" + (i + j + k));
}
}
class SimpleInheritance {
public static void main(String args[])
{
B subob = new B();
subob.i = 5;
subob.j = 6;
subob.k = 9;
System.out.println("The contents are");
subob.showk();
subob.sum();
}
}
a) Run-time error
b) Compilation error
c) Output: The contents are k: 9
d) None of the mentioned
View Answer
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.