The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+11 votes
1.1k views

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 get name, getId and compute salary are required. Given the class hierarchy below, possible locations for these functions are:

  1. getId is implemented in the superclass

  2. getId is implemented in the subclass

  3. getName is an abstract function in the superclass

  4. getName is implemented in superclass

  5. getName is implemented in subclass

  6. getSalary is an abstract function in the superclass

  7. getSalary is implemented in the superclass

  8. getSalary is implemented in the subclass

Choose the best design

  1. I, IV, VI, VIII
  2. I, IV, VII
  3. I, III, V, VI, VIII
  4. II, V, VIII
asked in Object Oriented Programming by Veteran (59.7k points) | 1.1k views

4 Answers

+23 votes
Best answer
A.

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 a abstract function in superclass and implemented in subclass.
answered by Veteran (369k points)
selected by
0
lovely explanation arjun sir
+1 vote
ans c)
answered by Loyal (5.3k points)
0
Why getName should be in subclass?
+1 vote
Getid() and GetName() can be there in the super 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 super class. And all subclasses should implement salary according to their category.
answered by Junior (815 points)
–1 vote
Ans is C

GetId is unique so it will represent in  superclass

Get name and salary are not unique do they will be represented in subclass and abstract from the superclass
answered by Active (2.6k points)
Answer:

Related questions



Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

44,284 questions
49,773 answers
164,284 comments
65,856 users