OOPS

Question 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:

    (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)
Question 1 Explanation: 
Name and id are a property of every employee and independent of their category. So these should be implemented in superclass. Every employee has a salary but this is determined by their category. So getsalary must be abstract function in superclass and implemented in subclass.
Question 2
The feature in object-oriented programming that allows the same operation to be carried out differently, depending on the object, is:
A
Inheritance
B
Polymorphism
C
Over functioning
D
Overriding
Question 2 Explanation: 
In object-oriented programming, inheritance is the mechanism of basing an object or class upon another object (prototype-based inheritance) or class (class-based inheritance), retaining similar implementation.

In any object-oriented programming language,Overriding is a feature that allows a subclass or child class to provide a specific implementation of a method that is already provided by one of its superclasses or parent classes

Polymorphism is the provision of a single interface to entities of different types or the use of a single symbol to represent multiple different types
There are 2 questions to complete.

Access quiz wise question and answers by becoming as a solutions adda PRO SUBSCRIBER with Ad-Free content

Register Now

If you have registered and made your payment please contact solutionsadda.in@gmail.com to get access