OOPS
Question 1 |
A software engineer is required to implement two sets of algorithms for a single set of matrix operations in an object oriented programming language; the two sets of algorithms are to provide precisions of 10-3 and 10-6, respectively. She decides to implement two classes, Low Precision Matrix and High Precision Matrix, providing precisions 10-3 and 10-6 respectively. Which one of the following is the best alternative for the implementation?
- (S1) The two classes should be kept independent.
(S2) Low Precision Matrix should be derived from High Precision Matrix.
(S3) High Precision Matrix should be derived from Low Precision Matrix.
(S4) One class should be derived from the other; the hierarchy is immaterial.
A | S1 |
B | S2 |
C | S3 |
D | S4 |
Question 2 |
Run-time polymorphism is achieved by
A | friend function |
B | virtual function
|
C | operator overloading |
D | function overloading |
Question 3 |
The operator that cannot be overloaded is
A | ++ |
B | :: |
C | 0 |
D | ~ |
Question 4 |
The keyword friend does not appear in
A | the class allowing access to another class |
B | the class desiring access to another class |
C | the private section of a class
|
D | the public section of a class |
Question 5 |
A | Type |
B | Set of operations on that type |
C | How the type is implemented |
D | (A) and (B) |
Question 6 |
A | User interface class |
B | System class |
C | Business domain class |
D | Process class |
Question 7 |
A | C++ |
B | Java |
C | Both C++ and Java |
D | None |
Question 8 |
A | Private and protected members |
B | Public members only |
C | Private members only |
D | None |
Question 9 |
The C++ statement cout <<(0 ==0) will
A | Outputs as 0 |
B | Outputs as 1 |
C | Generate error at the time of compilation
|
D | Generate run time |
Question 10 |
A | Copy constructor |
B | Friend constructor |
C | Default constructor |
D | Parameterized constructor |
Default constructors: If the programmer does not supply a constructor for an instantiable class, Java/C++ compiler inserts a default constructor into your code on your behalf. This constructor is known as default constructor.
Copy Constructor: Copy constructors define the actions performed by the compiler when copying class objects. A Copy constructor has one formal parameter that is the type of the class (the parameter may be a reference to an object). It is used to create a copy of an existing object of the same class. Even though both classes are the same, it counts as a conversion constructor.
Question 11 |
A | function |
B | class |
C | object |
D | operator function |
Question 12 |
A | same as object
|
B | same as member |
C | same as class |
D | same as function |
Question 13 |
A | Classname objectname;
|
B | Class classname obj objectname; |
C | Class classname obj objectname; |
D | Classname obj objectname |
For example ,let there be some class of name Area. So we can declare object of Area class like,
Area A1;
Question 14 |
A | 1 |
B | 2 |
C | 3 |
D | as many as required |
Question 15 |
A | Serialization |
B | Garbage collection |
C | File Filtering |
D | All the given options |
Question 16 |
A | Returns a pointer to a variable
|
B | Creates a variable called new |
C | Obtains memory for a new variable |
D | Tells how much memory is available |
Question 17 |
A | Refer to current class object |
B | Refer to static method of the class
|
C | Refer to parent class object |
D | Refer to static variable of the class |
Question 18 |
A | Remove Method Invocation (RMI) |
B | Remote Procedure Calls (RPC) |
C | Multicast sockets |
D | Remote Method Invocation (RMI) or Remote Procedure Calls (RPC) |
Question 19 |
A | Private |
B | Protected |
C | Public |
D | Friend |
Question 20 |
A | Java applets can not be written in any programming language |
B | An applet is not a small program |
C | An applet can be run on its own |
D | Applets are embedded in another applications |
Question 21 |
Which of the following statement is false for class B?
A | Member function of class B can access protected data of class A |
B | Member function of class access public data of class A |
C | Member function of class B cannot access private data of class A |
D | Object of derived class B can access public base class data |
B→ Derived class from A with protected inheritance.
The friend functions and the member functions of a friend class can have direct access to both the PRIVATE and PROTECTED data, the member functions of a derived class can directly access only the PROTECTED data.
However, they can access the PRIVATE data through the member functions of the base class TRUE: Member function of class B can access protected data of class A
TRUE: Member function of class access public data of class A
FALSE: Member function of class B cannot access private data of class A
TRUE: Object of derived class B can access public base class data
Question 22 |
Which of the following statements are true regarding C++?
(a) Overloading gives the capacity to an existing operator to operate on other data types.
(b) Inheritance in object oriented programming provides support to reusability.
(c) When object of a derived class is defined, first the constructor of derived class in executed then constructor of a base class is executed.
(d) Overloading is a type of polymorphism. Choose the correct option from those given below:
A | (a) and (b) only |
B | (a), (b) and (c) only |
C | (a), (b) and (d) only |
D | (b), (c) and (d) only |
TRUE: Inheritance in object oriented programming provides support to reusability.
FALSE: When object of a derived class is defined, first the constructor of derived class in executed then constructor of a base class is executed.
2 important points Order of Constructor Call with Inheritance in C++
1. Whether derived class’s default constructor is called or parameterised is called, base class’s default constructor is always called inside them.
2. To call base class’s parameterised constructor inside derived class’s parameterised constructor, we must mention it explicitly while declaring derived class’s parameterized constructor.
TRUE: Overloading is a type of polymorphism.
Question 23 |
A | Class loader only |
B | Class loader and Java Interpreter |
C | Class loader, Java Interpreter and API |
D | Java Interpreter only |
Question 24 |
A | Date::Date(int dd) {/*…*/} |
B | explicit Date::Date(int dd) {/*…*/} |
C | Such a constructor cannot be defined |
D | Constructor always has to be defined inside the class |
class class_name {
public:
class_name();
};
// Defining a Constructor Outside of the Class by using :: operator
class_name::class_name()
{
}
Question 25 |
List I List II
(A) Localization (I) Encapsulation
(B) Packaging or binding of a collection of items (II) Abstraction
(C) Mechanism that enables designer to focus on essential details of a program component (III) Characteristics of software that indicate the manner in which information is concentrated in a program.
(D) Information hiding (IV) Suppressing the operational details of a program component
Choose the correct answer from the options given below:
A | (A)-(I), (B)-(II), (C)-(III), (D)-(IV) |
B | (A)-(II), (B)-(I), (C)-(III), (D)-(IV) |
C | (A)-(III), (B)-(I), (C)-(II), (D)-(IV) |
D | (A)-(III), (B)-(I), (C)-(IV), (D)-(II) |
Question 26 |
A | To enable the JVM to make call to the main( ), as class has not been instantiated. |
B | To enable the JVM to make call to the main( ), as class has not been inherited. |
C | To enable the JVM to make call to the main( ), as class has not been loaded. |
D | To enable the JVM to make call to the main( ), as class has not been finalized. |
Question 27 |
A | Serializable Interface |
B | Utilization Interface |
C | Threadable Interface |
D | Recognizable Interface |
Question 28 |
class Dialog1
{
public static void main(String args[])
{
Frame f1=new Frame(“INDIA”);
f1.setSize(300,300);
f1.setVisible(true);
FileDialog d=new FileDialog(f1, “MyDialog”);
d.setVisible(true);
String fname=d.getDirectory()+d.getFile();
System.out.println(“The Selection is”+fname);
}
}
To make the Frame visible, which of the following statements are true?
A | f1.setClear(true); |
B | f1.setVisible(true); |
C | f1.setlook(true); |
D | f1.setclean(true); |
Question 29 |
A | Single try can have multiple associated catch with it |
B | A Single Catch can have multiple try associated with it |
C | Finally block execute only when the class is inherited |
D | For a given exception, multiple catch can execute |
Question 30 |
A | Overloading and linking |
B | Overriding and linking |
C | Reusability and data-hiding |
D | Overloading and Overriding |
Overriding occurs when two methods have the same method name and parameters. One of the methods is in the parent class, and the other is in the child class. Overriding allows a child class to provide the specific implementation of a method that is already present in its parent class.
Question 31 |
(a) A publicly derived class is a subtype of its base class.
(b) Inheritance provides for code reuse.
A | Both the statements (a) and (b) are correct. |
B | Neither of the statements (a) and (b) are correct |
C | Statement (a) is correct and (b) is incorrect |
D | Statement (a) is incorrect and (b) is correct. |
→ Inheritance is defined as deriving new classes (sub classes) from existing ones (super class or base class) and forming them into a hierarchy of classes.
→ Inheritance allows programmers to create classes that are built upon existing classes, to specify a new implementation while maintaining the same behaviors (realizing an interface), to reuse code and to independently extend original software via public classes and interfaces.
Question 32 |
A | terminate( ) |
B | unexpected( ) |
C | abort( ) |
D | kill( ) |
The exception handling mechanism cannot find a handler for a thrown exception. The following cases are more specific:
1. During stack unwinding, a destructor throws an exception and that exception is not handled.
2. The expression that is thrown also throws an exception, and that exception is not handled.
3. The constructor or destructor of a nonlocal static object throws an exception, and the exception is not handled.
4. A function registered with atexit() throws an exception, and the exception is not handled. The following demonstrates this:
A throw expression without an operand tries to rethrow an exception, and no exception is presently being handled.
Question 33 |
A | The member functions of the class generating friendship can access the members of the friend class. |
B | All member functions of the class granted friendship have unrestricted access to the members of the class granting the friendship. |
C | Class friendship is reciprocal to each other. |
D | There is no such concept. |
→ Although the entire second class must be a friend to the first class, you can select which functions in the first class will be friends of the second class.
Question 34 |
A | Overloads |
B | Friendships |
C | Inherits |
D | Overrides |
Question 35 |
A | A function can only be declared a friend by a class itself. |
B | Friend functions are not members of a class, they are associated with it. |
C | Friend functions are members of a class. |
D | It can have access to all members of the class, even private ones. |
TRUE: function can only be declared a friend by a class itself.
TRUE: Friend functions are not members of a class, they are associated with it.
FALSE:Friend functions are members of a class.
TRUE: It can have access to all members of the class, even private ones.
Question 36 |
switch(x)
{
default;
system.out.println(“Hello”);
}
Which of the following data types are acceptable for x?
A | Byte and char |
B | Long and char |
C | Char and float |
D | Byte and float |
Question 37 |
- Math.max(1,4)
- Math.max(2.3,5)
- Math.max(1,3,5,7)
- Math.max(-1.5,-2.8f)
A | A,b and d |
B | B,c and d |
C | A,b and c |
D | C and d |
→We can find the greater of any two data types variables.
→Option C consists of four variables , So it is invalid.
Question 38 |
A | Before a variable can be used, it must be declared |
B | Variable are allocated values through the use of assignment statements |
C | When a variable is declared, C++ allocates storage for the variable and puts an unknown value inside it. |
D | We can use a variable even if it is not declared. |
Question 39 |
A | Each public member in the base class is protected in the derived class |
B | Each protected member in the base class is protected in the derived class |
C | Each private member in the base class is private in the derived class |
D | Each private member in the base class is visible in the derived class |

Question 40 |
A | Protected and public data only in C and B |
B | Protected and public data only in C |
C | Private data in A and B |
D | Protected data in A and B |

Question 41 |
A | Polymorphism |
B | Single inheritance |
C | Multilevel inheritance |
D | Message passing |
Question 42 |
A | Public |
B | Private |
C | Protected |
D | Mandatory to specify |
→The private members are not accessible outside the class; they can be accessed only through methods of the class. The public members form an interface to the class and are accessible outside the class.
Question 43 |
A | 1 byte |
B | 2 byte |
C | 4 byte |
D | 8 byte |


Question 44 |
A | Student student(){} |
B | Private final student(){} |
C | Student(student s){} |
D | Void student(){} |
Question 45 |
A | “is a kind of” relationship |
B | “has a” relationship |
C | “want to be” relationship |
D | “contains” of relationship |
Aggregation–>”Has a” relationship
Question 46 |
What is the output of the following JAVA program ?
class simple { public static void main(String[] args) { simple obj = new simple(); obj.start(); } void start() { long [] P = {3, 4, 5}; long [] Q = method (P); System.out.print (P[0] + P[1] + P[2]+”:”); System.out.print (Q[0] + Q[1] + Q[2]); } long [] method (long [] R) { R [1] = 7; return R; } } //end of class
A | 12 : 15 |
B | 15 : 12 |
C | 12 : 12 |
D | 15 : 15 |
• By using object , we call the function start( ).
• In the start() function definition, first statement is integer array with three elements.
• long [ ] Q= method (P); Again function method(p) will be called.
• In the definition of method function, we are changing the second element of array to value 7 and returning updated array to array Q.
• We are passing address of P as argument to method so Modifications happened in the method automatically reflects to array P.
• Both array P and Q consists of values {3,7,5}.
• The sum of the three values are 15.
Question 47 |
In Java, which of the following statements is/are True ?
-
S1 : The ‘final’ keyword applied to a class definition prevents the class from being extended through derivation.
S2 : A class can only inherit one class but can implement multiple interfaces.
S3 : Java permits a class to replace the implementation of a method that it has inherited. It is called method overloading.
A | S1 and S2 only |
B | S1 and S3 only |
C | S2 and S3 only |
D | All of S1, S2 and S3
|
• The final keyword in java is used to restrict the user. The java final keyword can be used in many context. Final can be: variable, method and class.
• A Java class can only extend one parent class. Multiple inheritance (extends) is not allowed. Interfaces are not classes. However, and a class can implement more than one interface.
Question 48 |
Which of the following statements is/are True ?
P : C programming language has a weak type system with static types. Q : Java programming language has a strong type system with static types. Code :A | P only |
B | Q only |
C | Both P and Q |
D | Neither P nor Q
|
→ A weakly typed language has looser typing rules and may produce unpredictable results or may perform implicit type conversion at runtime.
→ Java, C#, Ada and Pascal are sometimes said to be more strongly typed than C, a claim that is probably based on the fact that C supports more kinds of implicit conversions, and C also allows pointer values to be explicitly cast while Java and Pascal do not.
→ Java itself may be considered more strongly typed than Pascal as manners of evading the static type system in Java are controlled by the Java virtual machine’s type system.
→ C# and VB.NET are similar to Java in that respect, though they allow disabling of dynamic type checking by explicitly putting code segments in an “unsafe context”.
→ Pascal’s type system has been described as “too strong”, because the size of an array or string is part of its type, making some programming tasks very difficult.
Question 49 |
1 public class While
2 {
3 public void loop()
4 {
5 int x = 0;
6 while(1)
7 {
8 System.out.println(“x plus one is” +(x+1));
9 }
10 }
11 }
A | There is syntax error in line no. 1 |
B | There is syntax errors in line nos. 1 & 6 |
C | There is syntax error in line no. 8 |
D | There is syntax error in line no. 6 |
So we cannot use integers in the while() statement.
So line number 6 will give syntax error.
Question 50 |
A | extern |
B | static |
C | volatile |
D | const |
→ The static modifier may also be applied to global variables. When this is done, it causes that variable’s scope to be restricted to the file in which it is declared.
→ In C programming, when static is used on a global variable, it causes only one copy of that member to be shared by all the objects of its class.