OOP Concepts
Question 1 |
Which one of the following are essential features of an object-oriented programming language? (GATE CS 2005)
(i) Abstraction and encapsulation
(ii) Strictly-typedness
(iii) Type-safe property coupled with sub-type rule
(iv) Polymorphism in the presence of inheritance
Answer (b)
Abstraction, Encapsulation, Polymorphism and Inheritance are the essential features of a OOP Language (See the Wiki page for OOP).
(i) and (ii) only | |
(i) and (iv) only | |
(i), (ii) and (iv) only | |
(i), (iii) and (iv) only |
Discuss it
Question 1 Explanation:
Abstraction, Encapsulation, Polymorphism and Inheritance are the essential features of a OOP Language (See the Wiki page for OOP).
Question 2 |
It is desired to design an object-oriented employee record system for a company. Each employee has a name, unique id and salary. Employees belong to different categories and their salary is determined by their category. The functions to get Name, getld and compute salary are required. Given the class hierarchy below, possible locations for these functions are:
i. getld is implemented in the superclass
ii. getld is implemented in the subclass
iii. getName is an abstract function in the superclass
iv. getName is implemented in the superclass
v. getName is implemented in the subclass
vi. getSalary is an abstract function in the superclass
vii. getSalary is implemented in the superclass
viii. getSalary is implemented in the subclass
Choose the best design

(i), (iv), (vi), (viii) | |
(i), (iv), (vii) | |
(i), (iii), (v), (vi), (viii) | |
(ii), (v), (viii) |
Discuss it
Question 2 Explanation:
See Question 1 of http://www.geeksforgeeks.org/object-oriented-programming-set-1/
Question 3 |
Consider the following class definitions in a hypothetical Object Oriented language that supports inheritance and uses dynamic binding. The language should not be assumed to be either Java or C++, though the syntax is similar.
Class P { void f(int i) { print(i); } } Class Q subclass of P { void f(int i) { print(2*i); } }Now consider the following program fragment:
P x = new Q(); Q y = new Q(); P z = new Q(); x.f(1); ((P)y).f(1); z.f(1);Here ((P)y) denotes a typecast of y to P. The output produced by executing the above program fragment will be
1 2 1 | |
2 1 1 | |
2 1 2 | |
2 2 2 |
Discuss it
Question 3 Explanation:
As we are not using virtual function in the classes so, the early binding will happen here i.e., compiler will bind the object with a function by seeing the type of the object/pointer, not the address which they will be storing during run time.
Question 4 |
i-b, ii-d, iii-e, iv-f, v-g, vi-a | |
i-c, ii-a, iii-e, iv-d, v-h, vi-f | |
i-c, ii-f, iii-h, iv-a, v-g, vi-d | |
i-b, ii-e, iii-c, iv-f, v-g, vi-s |
Discuss it
Question 5 |
Which one of the following are essential features of object oriented language?
A. Abstraction and encapsulation
B. Strictly-typed
C. Type-safe property coupled with sub-type rule
D. Polymorphism in the presence of inheritance
A and B only | |
A, D and B only | |
A and D only | |
A, C and D only |
Discuss it
Question 5 Explanation:
Refer: GATE-CS-2005 | Question 4
Option (C) is correct.
Question 6 |
Which of the following is associated with objects?
State | |
Behaviour | |
Identity | |
All of the above |
Discuss it
Question 7 |
Abstraction and encapsulation are fundamental principles that underlie the object oriented approach to software development. What can you say about the following two statements ?
I. Abstraction allows us to focus on what something does without considering the complexities of how it works.
II. Encapsulation allows us to consider complex ideas while ignoring irrelevant detail that would confuse us.
Neither I nor II is correct. | |
Both I and II are correct. | |
Only II is correct. | |
Only I is correct. |
Discuss it
Question 7 Explanation:
Encapsulation allows us to focus on what something does without considering the complexities of how it works.
Abstraction allows us to consider complex ideas while ignoring irrelevant detail that would confuse us.
So, option (A) is correct.
Question 8 |
Consider the following two statements:
(a)A publicly derived class is a subtype of its base class.
(b)Inheritance provides for code reuse.
Both the statements (a) and (b) are correct. | |
Neither of the statements (a) and (b) are correct | |
Statement (a) is correct and (b) is incorrect | |
Statement (a) is incorrect and (b) is correct. |
Discuss it
Question 8 Explanation:
- A publicly derived class is a subtype of its base class.
- Inheritance provides for code reuse.
Question 9 |
Which of the following statements regarding the features of the object-oriented approach to databases are true?
(a)The ability to develop more realistic models of the real world.
(b)The ability to represent the world in a non-geometric way.
(c)The ability to develop databases using natural language approaches.
(d)The need to split objects into their component parts.
(e)The ability to develop database models based on location rather than state and behaviour.
Codes:
(a), (b) and (c) | |
(b), (c) and (d) | |
(a), (d) and (e) | |
(c), (d) and (e) |
Discuss it
Question 9 Explanation:
Features of the object-oriented approach to databases:
The ability to develop more realistic models of the real world.
The ability to represent the world in a non-geometric way.
The ability to develop databases using natural language approaches.
So, option (A) is correct.
Question 10 |
The feature in object-oriented programming that allows the same operation to be carried out differently, depending on the object, is:
Inheritance | |
Polymorphism | |
Overfunctioning | |
Overriding |
Discuss it
There are 12 questions to complete.