Docsity

CERTIFIED SOLIDITY DEVELOPER (CSD) - ULTIMATE PRACTICE EXAM, Exams of Nursing

Toggle sidebar
bg1
1 | P a g e
CERTIFIED SOLIDITY
DEVELOPER (CSD) - ULTIMATE
PRACTICE EXAM
## Exam Structure
- Total Questions: 250 Multiple Choice
- Format: Questions followed immediately by answer, explanation,
and reference
- Content Areas: Solidity fundamentals, security, token standards,
testing, deployment, and advanced patterns
---
## SECTION A: SOLIDITY FUNDAMENTALS AND LANGUAGE
BASICS (40 Questions)
Question 1
Solidity is best described as which type of programming language?
- A) Dynamically typed, interpreted language
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58
pf59
pf5a
pf5b
pf5c
pf5d
pf5e
pf5f
pf60
pf61
pf62
pf63
pf64

Partial preview of the text

Download CERTIFIED SOLIDITY DEVELOPER (CSD) - ULTIMATE PRACTICE EXAM and more Exams Nursing in PDF only on Docsity!

CERTIFIED SOLIDITY

DEVELOPER (CSD) - ULTIMATE

PRACTICE EXAM

Exam Structure

  • Total Questions: 250 Multiple Choice
  • Format: Questions followed immediately by answer, explanation, and reference
  • Content Areas: Solidity fundamentals, security, token standards, testing, deployment, and advanced patterns

SECTION A: SOLIDITY FUNDAMENTALS AND LANGUAGE

BASICS (40 Questions) Question 1 Solidity is best described as which type of programming language?

  • A) Dynamically typed, interpreted language
  • B) Statically typed, object-oriented, high-level language for smart contracts
  • C) Low-level assembly language for the EVM
  • D) Functional programming language only Answer 1: B Explanation: Solidity is a statically typed, object-oriented (contract- oriented) high-level language designed specifically for implementing smart contracts on the Ethereum Virtual Machine (EVM). It is not dynamically typed or interpreted. Assembly languages like Yul exist for lower-level EVM programming. Question 2 What does the pragma solidity ^0.8.0; statement indicate?
  • A) The contract can be compiled with any compiler version
  • B) The contract can be compiled with version 0.8.0 and any newer minor version, but not 0.9.
  • C) The contract can only be compiled with version 0.8.
  • D) The contract is compatible with all versions of Solidity Answer 2: B
  • C) Checking for integer overflow
  • D) Emitting events Answer 4: B Explanation: require() is used to validate conditions—typically user inputs or external conditions. If the condition fails, the transaction reverts and refunds remaining gas. It should be used for input validation, whereas assert() is for internal invariants that should never fail. Question 5 Which function visibility modifier allows the function to be called from anywhere, including external accounts and other contracts?
  • A) private
  • B) internal
  • C) public
  • D) external Answer 5: C Explanation: public is the most permissive visibility modifier—it allows calls from both within the contract and from external

contracts/accounts. The order of restrictiveness (most to least) is private → internal → external → public. Question 6 What is the difference between view and pure functions in Solidity?

  • A) There is no difference
  • B) view reads state but does not modify it; pure neither reads nor modifies state
  • C) pure reads state but does not modify it; view does neither
  • D) Both can modify state but in different ways Answer 6: B Explanation: view functions can read state variables but cannot modify them. pure functions cannot even read state variables—they are purely computational, depending only on their inputs. Both indicate the function does not alter the blockchain state. Question 7 In the Solidity code mapping(address => uint256) public balances;, what does public do?
  • A) It makes the mapping visible only within the contract

authorization is a security vulnerability because a malicious contract can spoof it. Question 9 What is the purpose of the payable keyword in Solidity?

  • A) To indicate a function can receive Ether
  • B) To mark a function as private
  • C) To make a function view-only
  • D) To declare a function as abstract Answer 9: A Explanation: The payable keyword allows a function to receive Ether. Without it, a function will reject any Ether sent to it. It is also used with the receive() and fallback() functions to indicate they can accept Ether. Question 10 What is the default value of a bool variable in Solidity?
  • A) true
  • B) false
  • C) null
  • D) Undefined Answer 10: B Explanation: The default value for a bool is false. For address, the default is 0x0000000000000000000000000000000000000000 (zero address). For enum, the default is the first member. Question 11 Which data location is used for variables that persist permanently on the blockchain?
  • A) memory
  • B) storage
  • C) calldata
  • D) stack Answer 11: B Explanation: storage is the persistent data area that exists on the blockchain. State variables default to storage. memory is temporary and exists only during function execution. calldata is read-only and contains the function call data. Question 12

Explanation: The receive() function is a special function executed when a contract receives plain Ether without any calldata. It must have external visibility and can be marked payable. If a contract receives Ether without receive() or a payable fallback(), the transaction reverts. Question 14 What is the correct way to handle errors in Solidity when making low- level calls?

  • A) Assume the call succeeds and continue execution
  • B) Check the return value of the call and handle the failure
  • C) Use revert() after every call
  • D) Ignore the return value to save gas Answer 14: B Explanation: Low-level calls like call(), delegatecall(), and send() return a boolean success value rather than automatically reverting. It is essential to check this return value and handle failures appropriately. Ignoring return values can lead to silent failures and vulnerabilities. Question 15

Which keyword is used to define a constructor in Solidity?

  • A) constructor
  • B) init
  • C) initialize
  • D) new Answer 15: A Explanation: The constructor keyword is used to define a constructor, which is executed once during contract deployment. In older Solidity versions, the function with the same name as the contract served as the constructor. Question 16 Events in Solidity are primarily used for:
  • A) Storing persistent data on the blockchain
  • B) Logging activity for off-chain applications to monitor
  • C) Controlling access to functions
  • D) Reducing gas costs Answer 16: B
  • C) To mark a contract as upgradeable
  • D) To define an interface Answer 18: B Explanation: Modifiers are used to change the behavior of functions in a declarative way. They are commonly used for access control (e.g., onlyOwner), validation, or to prevent reentrancy (e.g., nonReentrant). They help reduce code duplication. Question 19 In Solidity, what is the difference between call() and delegatecall()?
  • A) delegatecall changes the caller's state; call changes the callee's state
  • B) delegatecall is cheaper than call
  • C) There is no difference
  • D) call is deprecated in newer versions Answer 19: A Explanation: delegatecall executes code from another contract but in the context (storage, msg.sender, msg.value) of the calling

contract. call executes code in the context of the called contract. delegatecall is used in proxy patterns for upgradeability. Question 20 What is the maximum number of topics (indexed parameters) an event can have?

  • A) 2
  • B) 3
  • C) 4
  • D) 5 Answer 20: C Explanation: Events can have up to 4 indexed parameters (topics). The first topic is always the event signature hash, leaving three additional topics for indexed parameters. Indexed parameters can be searched for by off-chain applications. Question 21 Which of the following is NOT a valid visibility modifier for functions in Solidity?
  • A) internal
  • B) private

Question 23 What does the fallback() function do in Solidity?

  • A) It is executed when the contract receives Ether with calldata or when a function is called that does not exist
  • B) It is only for sending Ether to other contracts
  • C) It is called automatically when a transaction fails
  • D) It is used for emergency contract pausing Answer 23: A Explanation: The fallback() function is executed when a function identifier does not match any function in the contract, or when the contract receives plain Ether (if receive() is not present). It must be external and can be payable. It is often used with only 2300 gas forwarded. Question 24 What is the gas cost implication of using require() vs assert()?
  • A) require() refunds gas on failure; assert() consumes all gas
  • B) assert() refunds gas on failure; require() consumes all gas
  • C) Both functions have identical gas behavior
  • D) Neither function affects gas Answer 24: A Explanation: When require() fails, any remaining gas is refunded to the caller. When assert() fails, all gas is consumed and not refunded. This is because assert() is intended for internal errors/invariants, while require() is for user input validation. Question 25 In Solidity, how do you declare an enum?
  • A) enum Status { Pending, Active, Closed }
  • B) enum Status { "Pending", "Active", "Closed" }
  • C) type Status = [Pending, Active, Closed]
  • D) enum Status { 1: Pending, 2: Active, 3: Closed } Answer 25: A Explanation: Enums in Solidity are declared with enum followed by the name and the list of possible values. They are value types and can be used as state variables. The first value is the default (index 0) . Question 26

What does the address type's .balance member return?

  • A) The total number of transactions sent from the address
  • B) The Ether balance of the address in wei
  • C) The code hash of the address
  • D) The nonce of the address Answer 27: B Explanation: address.balance returns the Ether balance of the address in wei (the smallest Ether unit). It is a read-only property. The address.code property returns the code hash, and address.codehash returns the actual code hash. Question 28 What is the purpose of abi.encodePacked() in Solidity?
  • A) To pack data tightly and produce a bytes array
  • B) To decrypt encrypted data
  • C) To encode a function signature
  • D) To generate a random number Answer 28: A

Explanation: abi.encodePacked() performs tight packing of arguments without padding, producing a bytes array. It is commonly used for creating hashes with keccak256(). However, it should be used with caution as it can lead to hash collisions if used for signatures. Question 29 Which of the following is a correct statement about selfdestruct in Solidity?

  • A) It sends Ether to the deployer and deletes the contract code
  • B) It sends Ether to a specified address and removes the contract from the blockchain
  • C) It only deletes the contract code but keeps the storage
  • D) It is no longer supported in Solidity Answer 29: B Explanation: selfdestruct sends all Ether from the contract to a specified address and removes the contract code and storage. This operation is final and cannot be undone. A contract can receive Ether via selfdestruct even without a payable function. Question 30