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 |
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 3 |
A | Serializable Interface |
B | Utilization Interface |
C | Threadable Interface |
D | Recognizable Interface |
Question 4 |
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 5 |
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 6 |
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 7 |
A | (A), (B) and (C) are false. |
B | (A) and (B) are true; (C) is false.
|
C | A) is true; (B) and (C) are false. |
D | (A), (B) and (C) are true. |
TRUE: To implement ADT, a programming language requires some primitive operations that are built in the language processor.
TRUE: C++, Ada, Java 5.0, C#2005 provide support for parameterised ADT.
Question 8 |
A | (a)-(i), (b)-(iii), (c)-(iv), (d)-(ii) |
B | (a)-(iv), (b)-(i), (c)-(iii), (d)-(ii) |
C | (a)-(iii), (b)-(i), (c)-(iv), (d)-(ii) |
D | (a)-(ii), (b)-(i), (c)-(iii), (d)-(iv)
|
Stack dynamic→ Local variables in Pascal
Explicit heap dynamic→ All objects in JAVA
Implicit heap dynamic→ All variables in APL
Question 9 |
A | not of class type itself |
B | class type itself |
C | a destructor of class type |
D | a destructor not of class type |
Syntax For Constructors:
Access_Modifier No Return_Type Class(...)
Example:
public static main(String [ ]args)
Constructor rules:
1. Constructors are always used with a new.
2. Have the same name as that of Class
3. Does not have a return type
4. Can be Overloaded but not Overridden.
Question 10 |
A | 2 |
B | 3 |
C | 4 |
D | 5 |
1. Static
2. Non static.
Nested classes that are declared static are simply called static nested classes.
Non static nested classes are called inner classes.
Question 11 |
A | Aggregation is a strong type of association between two classes with full ownership |
B | Aggregation is a strong type of association between two classes with partial ownership. |
C | Aggregation is a weak type of association between two classes with partial ownership. |
D | Aggregation is a weak type of association between two classes with full ownership. |
For example consider two classes Student class and Address class. Every student has an address so the relationship between student and address is a Has-A relationship. But if you consider its vice versa then it would not make any sense as an Address doesn’t need to have a Student necessarily.
Question 12 |
(1) Every class containing abstract method must not be declared abstract.
(2) Abstract class cannot be directly initiated with ‘new’ operator.
(3) Abstract class cannot be initiated.
(4) Abstract class contains definition of implementation.
A | (1) |
B | (2) |
C | (2) and (3) |
D | All are correct. |
• Abstract method means method without body, we can also be called as pure virtual functions.
• If a class is marked with keyword abstract then it is called an abstract class. It can NOT be instantiated by using new operator. But an abstract class can be used as the superclass reference for the subclass object.
• Abstract classes, by design, are not complete or functional. They are meant to serve as a base from which complete classes can be built, by aggregating the common members and methods that they all will need into an abstract base class, and then allowing the inheriting classes to fill out the necessary details. So abstract class can’t be instantiated
Question 13 |
A | a copy of the object is created. |
B | a copy of the reference is created. |
C | a copy of the reference is not created. |
D | it is illegal to assign one object reference variable to another object reference variable. |
• A reference variable must be initialized at the time of declaration.
Question 14 |
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 15 |
A | function |
B | class |
C | object |
D | operator function |
Question 16 |
A | same as object
|
B | same as member |
C | same as class |
D | same as function |
Question 17 |
What is the output of the following program:
#include
class sample
{
private int a,b’
public: void test ( )
{
a = 100;
b = 200;
}
friend int compute (sample e1);
};
int compute (sample e1)
{
return int (e1.a + e1.b) - 5;
}
Main ( )
{
Sample e;
e.test( );
Cout < < compute(e);
}
A | 205 |
B | 300 |
C | 295 |
D | error |
Question 18 |
A | Top-down |
B | Bottom-up |
C | Right-left |
D | Left-right |
Question 19 |
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 20 |
A | 1 |
B | 2 |
C | 3 |
D | as many as required |
Question 21 |
A | Serialization |
B | Garbage collection |
C | File Filtering |
D | All the given options |
Question 22 |
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 23 |
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 24 |
A | Remove Method Invocation (RMI) |
B | Remote Procedure Calls (RPC) |
C | Multicast sockets |
D | Remote Method Invocation (RMI) or Remote Procedure Calls (RPC) |
Question 25 |
If a class C is derived from class B which is derived from class A, all though public inheritance, then a class C member function can access
A | protected and public data in C and B
|
B | protected and public data only C |
C | private data in A and B
|
D | protected data in A and B |
Question 26 |
In C++ operator, << operator is called as
A | an insertion operator or put to operator |
B | an extraction operator or get from operator
|
C | an insertion operator or get from operator |
D | None of the given options |
Question 27 |
Function overloading in C++ is
A | A group function with the same name
|
B | all have the same numbers and type of arguments
|
C | functions with same name and same numbers and same type of arguments
|
D | None of the given options |
Question 28 |
How constructor differ from destructor?
A | Constructors can be overloaded but destructors can’t be overloaded |
B | Constructors can take arguments but destructor can’t |
C | Constructors can be overloaded but destructors can’t be overloaded and Constructors can take arguments but destructor can’t
|
D | None of the given options
|
Destructors cant be overloaded because your code wouldn't have a clue about which destructor it needs to call when you destroy an object.
Question 29 |
Abstract class cannot have
A | zero instance |
B | multiple instance
|
C | Both zero instance and multiple instance
|
D | None of the given options |
Question 30 |
Usually a pure virtual function
A | has complete function body |
B | will never be called |
C | will be called only to delete an object
|
D | is defined only in derived class
|
Question 31 |
If x=5, y=2, then x^y equals (where, ^ is a bitwise XOR operator)
A | 00000111 |
B | 10000010
|
C | 10100000 |
D | 11001000 |
1 XOR 1 = 0
1 XOR 0 =1
0 XOR 0 = 0
0 XOR 1 = 1
So 5 in binary form is 00000101 and 2 in binary form is 00000010.
Hence 00000101 XOR 00000010 = 00000111.
Question 32 |
Run-time polymorphism is achieved by
A | friend function |
B | virtual function
|
C | operator overloading |
D | function overloading |
Question 33 |
The operator that cannot be overloaded is
A | ++ |
B | :: |
C | 0 |
D | ~ |
Question 34 |
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 35 |
A | C++ |
B | Java |
C | Both C++ and Java |
D | None |
Question 36 |
A | Private and protected members |
B | Public members only |
C | Private members only |
D | None |
Question 37 |
A | Type |
B | Set of operations on that type |
C | How the type is implemented |
D | (A) and (B) |
Question 38 |
A | User interface class |
B | System class |
C | Business domain class |
D | Process class |
Question 39 |
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 40 |
Which of the following statements is true about C++ language?
A | C++ supports multiple inheritance |
B | C++ does not support operator overloading. |
C | C++ supports dynamic polymorphism
|
D | C++ supports interface definitions. |
E | Both A and D |
C++ supports operator overloading.
C++ supports static polymorphism.
C++ supports interface definitions.
Question 41 |
A | A data member of a class can be declared as static and is normally used to maintain values
common to the entire class. |
B | A friend function can be invoked like a normal function without the help of any object. |
C | The scope resolution operator (::) can overloaded like normal operators |
D | Multiple may lead to duplication of inherited members from a "Grandparent"
base class. This may be avoided by making the common base class a virtual base class.
|
Question 42 |
A | Class A {virtual void show() = 0; };
|
B | Class A {void show() = 0;};
|
C | Class A {void show() { } ; };
|
D | Class A {show() = 0; }; |
Question 43 |
(A)A constructor can be overloaded.
(B)A constructor does not have a return type.
(C)A constructor must be declared as a friend function.
(D)A constructor is called when an object is destroyed.
Choose the correct answer from the options green
A | (B), (C), (D) only
|
B | (B), (C) only
|
C | (A),(B), (C) only
|
D | (A),(B) Only |
Question 44 |
#include
Using namespace std;
class Base {
public:
Base(){
cout<<”Base const”;
}
Virtual ~Base()
{
cout<<”Base dest”;
}
};
class derived : public Base{
public:
Derived (){
cout<<”Derived Const”;
}
~ Derived(){
cout<< “Derived dest”;
}
};
int main ()
{
Base *b = new Derived ();
delete b;
return 0;
}
A | Base Const Derived Const Derived dest Base dest
|
B | Base Const Derived Const Base dest Derived dest
|
C | Derived Const Base Const Base dest Derived dest |
D | Base Const Derived Const Base dest
|
Question 45 |
A | &A[0][0][0]+w(b*c*s+c*r+t)
|
B | &A[0][0][0]+w(b*c*r*+c*s+t)
|
C | &A[0][0][0]+w(a*b*r*+c*s+t)
|
D | &A[0][0][0]+w(a*b*s+c*r+t) |
Question 46 |
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 47 |
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 48 |
A | Category |
B | Classification |
C | Combination |
D | Partial participation |
Question 49 |
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 50 |
A | Inheritance only |
B | Virtual functions only |
C | References only |
D | Inheritance, Virtual functions and references |
→ In C++, polymorphism requires inheritance, virtual functions and references
