Answered step by step
Verified Expert Solution
Question
1 Approved Answer
[ 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]
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 "unknownStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started