Question: [ Design Pattern ] 5 5 5 5+5 3. (a) Describe method overloading and overriding with example. (b) Explain the difference between Singleton and Prototype.
[Design Pattern]
![[Design Pattern] 5 5 5 5+5 3. (a) Describe method overloading and](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f32258b8558_07266f322582ecc0.jpg)
5 5 5 5+5 3. (a) Describe method overloading and overriding with example. (b) Explain the difference between Singleton and Prototype. (c) Write short notes on - "Duplicated code" and "Speculative Generality" (d) Consider the following three code snippets - Identify the code smells in the codes and rewrite the codes to remove the smells. i) function getPayAmount() { let result; if (isDead) result = deadAmount(); else { if (isseparated) result = separatedAmount(); else if (isRetired) result = retiredAmount); else result = normalPayAmount(); 3 return result; > ii) switch (bird.type) { case 'European Swallow': return "average": case 'African Swallow': return (bird. number of Coconuts > 2) ? "tired" : "average"; case 'NorwegianBlueParrot': return (bird.voltage > 100) ? "scorched" : "beautiful"; default: return "unknown
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
