forum - *Class, switch/case and If/else-if/else perform...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
*Class, switch/case and If/else-if/else perform almost the same purpose in flow control. Why have the two structures? What are the advantages and disadvantages of each? When should each be used? What are some examples that contrast their differences? Switch/case : Advantages : 1. it allows you to have multiple cases or statements organized in a sequential order. 2. It also has a special block statement which replaces the case keyword for the default key word. This when none of the values input it or given to the switch/ case statement is not found in the list of cases. 3. Readability and maintainability is easier than if/else-if/else, because it is more to the point or straight forward. 4. Another advantage is that it will execute faster Disadvantages: 1. It can fall through if the break keyword is not typed at the end of each case. However, only some languages allow fall though, but languages like C# will not allow it (therefore, this is an advantage in that particular language (C#), since it
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 3

forum - *Class, switch/case and If/else-if/else perform...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online