Answered step by step
Verified Expert Solution
Link Copied!

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]

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions