Recall & Review
beginner
What is an enum in blockchain programming?
An enum is a special type that lets you define a set of named values. It helps you group related options together, like days of the week or transaction states.
Click to reveal answer
beginner
Why use enums instead of plain numbers or strings?
Enums make code easier to read and less error-prone because you use meaningful names instead of numbers or strings. This helps prevent mistakes and makes your code clearer.
Click to reveal answer
beginner
How do you define an enum for transaction status with values: Pending, Completed, Failed?
You write something like:<br>
enum TransactionStatus { Pending, Completed, Failed }This groups the three states under one type.Click to reveal answer
intermediate
Can enums have underlying numeric values in blockchain languages?
Yes, enums often have underlying numbers starting from zero by default. You can also assign specific numbers if needed, which helps when storing or comparing values.
Click to reveal answer
intermediate
How do enums improve smart contract security?
Enums limit possible values to a fixed set, reducing bugs from invalid inputs. This helps smart contracts behave predictably and safely.
Click to reveal answer
What does an enum represent in blockchain programming?
✗ Incorrect
Enums define a fixed set of named values to represent related options clearly.
Which of these is a correct enum definition for colors?
✗ Incorrect
The correct syntax uses curly braces and commas to list enum values.
What is the default underlying value of the first enum member?
✗ Incorrect
By default, the first enum member has the numeric value 0.
How do enums help prevent bugs in smart contracts?
✗ Incorrect
Enums restrict values to a fixed set, reducing invalid inputs and bugs.
Can you assign specific numbers to enum members?
✗ Incorrect
You can assign specific numbers to enum members if you want custom values.
Explain what an enum is and why it is useful in blockchain programming.
Think about how enums help organize options like transaction states.
You got /4 concepts.
Describe how enums can improve the security and reliability of smart contracts.
Consider how limiting choices helps avoid mistakes.
You got /4 concepts.