search
Log In
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
13 votes
2.9k 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
in Object Oriented Programming 2.9k views

5 Answers

31 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.

selected by
0
lovely explanation arjun sir
0
What is difference between abstract function in the superclass and being implemented in the superclass i.e difference between option (3 and 4) and option(6 and 7)? Advance thanks for the help
3 votes
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.
1 vote
ans c)
0
Why getName should be in subclass?
0 votes
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.

Correct option should be A
–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
Answer:

Related questions

10 votes
5 answers
1
2.3k views
Which one of the following are essential features of an object-oriented programming language? Abstraction and encapsulation Strictly-typedness Type-safe property coupled with sub-type rule Polymorphism in the presence of inheritance I and II only I and IV only I, II and IV only I, III and IV only
asked Sep 22, 2014 in Object Oriented Programming Kathleen 2.3k views
42 votes
7 answers
2
8.1k views
Consider three IP networks $A, B$ and $C$. Host $H_A$ in network $A$ sends messages each containing $180$ $bytes$ of application data to a host $H_C$ in network $C$. The TCP layer prefixes $20$ byte header to the message. This passes through an intermediate network $B$. The maximum packet ... other overheads. $325.5$ $\text{Kbps}$ $354.5$ $\text{Kbps}$ $409.6$ $\text{Kbps}$ $512.0$ $\text{Kbps}$
asked Apr 24, 2016 in Computer Networks jothee 8.1k views
46 votes
4 answers
3
8.5k views
Consider the following program segment for a hypothetical CPU having three user registers $R_1, R_2$ and $R_3.$ \begin{array}{|l|l|c|} \hline \text {Instruction} & \text{Operation }& \text{Instruction size (in Words)} \\\hline \text{MOV $R_1,5000$} & \text{$R1$} \ ... text{2 clock cycles }\\\hline \end{array} The total number of clock cycles required to execute the program is $29$ $24$ $23$ $20$
asked Apr 24, 2016 in CO and Architecture jothee 8.5k views
33 votes
3 answers
4
5.3k views
Consider the grammar rule $E \rightarrow E1 - E2$ for arith­metic expressions. The code generated is targeted to a CPU having a single user register. The sub­traction operation requires the first operand to be in the register. If $E1$ and $E2$ do not have any com­mon ... first Evaluation of $E1$ and $E2$ should necessarily be interleaved Order of evaluation of $E1$ and $E2$ is of no consequence
asked Nov 12, 2014 in Compiler Design Vikrant Singh 5.3k views
...