Following questions have been asked in GATE CS exam.
1. 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: (GATE CS 2004)
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
(a) (i), (iv), (vi), (viii)
(b) (i), (iv), (vii)
(c) (i), (iii), (v), (vi), (viii)
(d) (ii), (v), (viii)
Getid() and GetName() can be there in the base class as these functions have the same implementation for all subclasses. As the question says that every employee must have salary and salary is determined by their category, getSalary() must be there as an abstract function in base class. And all subclasses should implement salary according to their category.
2. Which one of the following are essential features of an object-oriented programming language? (GATE CS 2005)
(i) Abstraction and encapsulation
(iii) Type-safe property coupled with sub-type rule
(iv) Polymorphism in the presence of inheritance
(a) (i) and (ii) only
(b) (i) and (iv) only
(c) (i), (ii) and (iv) only
(d) (i), (iii) and (iv) only
Abstraction, Encapsulation, Polymorphism and Inheritance are the essential features of a OOP Language (See the Wiki page for OOP).
Please see GATE Corner for all previous year paper/solutions/explanations, syllabus, important dates, notes, etc.
Please write comments if you find any of the answers/explanations incorrect, or you want to share more information about the topics discussed above.
- Difference between Connection-oriented and Connection-less Services
- Compiler Design | Introduction of Object Code
- Principle of programming languages | Set 1
- GATE CS 2016 Sec 5 – Dynamic Programming
- Read-Only Memory (ROM) | Classification and Programming
- Semantic Analysis in Compiler Design
- Basic Blocks in Compiler Design
- C-LOOK Disk Scheduling Algorithm
- Difference between Secure Socket Layer (SSL) and Secure Electronic Transaction (SET)
- Which is better, the GRE or the GATE?
- Variation of Turing Machine
- Difference between Deadlock and Starvation in OS
- Difference Between Security and Protection
- Join algorithms in Database