Recall & Review
beginner
What does the public visibility modifier mean in blockchain smart contracts?
A public function or variable can be accessed both internally within the contract and externally by other contracts or users.
Click to reveal answer
beginner
Explain the private visibility modifier.
A private function or variable is only accessible inside the contract where it is defined. It cannot be accessed by derived contracts or externally.
Click to reveal answer
intermediate
What is the difference between internal and private visibility?
Internal functions or variables can be accessed inside the contract and by contracts that inherit from it, while private ones are only accessible inside the defining contract.
Click to reveal answer
intermediate
When should you use the external visibility modifier?
External functions are meant to be called from other contracts or transactions, but not from within the same contract. They are efficient for functions called only externally.
Click to reveal answer
advanced
Can a public function call an external function internally?
No, a public function cannot call an external function internally using a simple function call. External functions require a message call (like a transaction). However, a public function can call an external function using this.<functionName>().
Click to reveal answer
Which visibility modifier allows access only within the contract it is defined in?
✗ Incorrect
Private members are accessible only inside the contract they are defined in.
Which visibility modifier allows access from derived contracts?
✗ Incorrect
Internal members can be accessed inside the contract and by contracts that inherit from it.
Which visibility modifier is designed to be called only from outside the contract?
✗ Incorrect
External functions are meant to be called from other contracts or transactions, not internally.
Can a public function be called from outside the contract?
✗ Incorrect
Public functions are accessible both internally and externally.
Which visibility modifier is the most restrictive?
✗ Incorrect
Private is the most restrictive, accessible only inside the defining contract.
Describe the four visibility modifiers used in blockchain smart contracts and give a simple example of when to use each.
Think about who can call the function or access the variable.
You got /4 concepts.
Explain why you might choose 'internal' over 'private' for a function in a smart contract.
Consider contract inheritance and extending functionality.
You got /3 concepts.