Hereβs a comprehensive Ethereum and Solidity multiple-choice quiz with 90 questions, covering topics from beginner to intermediate level. Each question has four options and one correct answer provided.
π§ Ethereum and Solidity Quiz (90 MCQs with Answers)
π Section 1: Ethereum Basics (1β30)
- What is Ethereum primarily used for?
A. File sharing
B. Smart contracts and DApps β
C. Image hosting
D. Traditional banking. - What is Ether (ETH)?
A. A hardware component
B. A stablecoin
C. A token standard
D. The native cryptocurrency of Ethereum β - Ethereum uses which consensus mechanism (before Ethereum 2.0)?
A. PoW β
B. PoS
C. DPoS
D. BFT - What does EVM stand for?
A. Ethereum Voting Machine
B. Ethereum Virtual Machine β
C. Elastic Virtual Machine
D. Elastic Voting Mechanism - Which language is most commonly used to write Ethereum smart contracts?
A. Python
B. Solidity β
C. Java
D. Ruby - What is “gas” in Ethereum?
A. Network bandwidth
B. A metric for contract complexity
C. Fuel for transactions and computation β
D. Ether balance - What are blocks in Ethereum?
A. Encrypted contracts
B. Bundles of transaction data β
C. Gas units
D. Tokens - What happens when gas runs out during a transaction?
A. Transaction is paused
B. Transaction fails and is reverted β
C. Transaction continues
D. Partial execution - Ethereum accounts are of two types:
A. Public and private
B. User and system
C. EOA and Contract β
D. Gas and No-Gas - Ethereum launched in:
A. 2012
B. 2013
C. 2014
D. 2015 β - Which of the following is true about a payable function in Solidity?
A. It can receive Ether β
B. It can send Ether automatically
C. It is used for gas estimation
D. It returns an event by default - What is the smallest denomination of Ether called?
A. Wei β
B. Finney
C. Gwei
D. Mwei - What does require() do in Solidity?
A. It declares a function
B. It reverts the transaction if a condition fails β
C. It logs an event
D. It returns a fallback - Which Ethereum client is written in Go?
A. Parity
B. Geth β
C. Besu
D. OpenEthereum - Which keyword is used to define a public variable in Solidity?
A. let
B. var
C. public β
D. visible - What is a fallback function in Solidity?
A. A function that is always public
B. A function called when no other function matches β
C. A function that logs errors
D. A function to override modifiers - Which command is used to deploy contracts using Hardhat?
A. npx hardhat compile
B. npx hardhat test
C. npx hardhat run scripts/deploy.js β
D. npx hardhat init - What is a block in Ethereum?
A. A fixed-size data structure
B. A container of multiple transactions β
C. A cryptographic algorithm
D. A validation node - Which of the following is used for upgrading smart contracts?
A. ABI
B. Proxy pattern β
C. Gas estimation
D. Truffle - What is the purpose of ABI in Ethereum?
A. Compress contract bytecode
B. Define token supply
C. Interface between contract and frontend β
D. Generate gas reports - What is the gas limit?
A. The total Ether in a block
B. The amount of data in a transaction
C. The maximum gas allowed for execution β
D. Number of blocks mined per second - What is msg.sender in Solidity?
A. The contract owner
B. The minerβs address
C. The address that called the function β
D. The signer of a transaction - What does the keyword view signify in Solidity?
A. The function can only write to storage
B. The function can read but not write to state β
C. It returns no value
D. It sends Ether - What is the return type of a function that doesn’t return anything in Solidity?
A. uint
B. null
C. void
D. none β - What does Truffle provide for Ethereum development?
A. Block scanning
B. IDE
C. Testing, compiling, and deploying framework β
D. Cloud wallet - What is the storage location of a mapping in Solidity?
A. Stack
B. Memory
C. Storage β
D. Calldata - What is the purpose of the constructor in Solidity?
A. Destroy contract
B. Initialize state on deployment β
C. Upgrade contract
D. Pause functions - Which of the following can emit events in Solidity?
A. Libraries
B. Contracts β
C. Constants
D. Fallback functions - How is inheritance supported in Solidity?
A. By linking libraries
B. Through interfaces
C. Using is keyword β
D. By using override only - What is the main difference between memory and storage in Solidity?
A. Memory is for constants
B. Memory is temporary, storage is persistent β
C. Storage is read-only
D. Memory is on-chain
π Section 2: Solidity Language (31β60)
- Solidity is a:
A. Compiled, high-level programming language β
B. Interpreted scripting language
C. Low-level language
D. Framework - What does pragma solidity ^0.8.0 mean?
A. Use only version 0.8.0
B. Use versions greater than 0.8.0
C. Use 0.8.0 or any higher compatible version β
D. Disable Solidity versioning - The keyword used to declare a contract is:
A. class
B. contract β
C. interface
D. pragma - To store Ether in a contract, which function modifier is used?
A. pure
B. view
C. payable β
D. constant - What is msg.sender?
A. Contract address
B. Caller of the function β
C. Miner address
D. Blockchain ID - What is the purpose of require() in Solidity?
A. Log output
B. Assert values
C. Revert if condition fails β
D. Import contracts
- What is the purpose of using interfaces in Solidity?
A. To add UI functionality
B. To inherit from abstract classes
C. To define a contractβs external functions without implementation β
D. To control Ether transfers - What type of value does a mapping return if the key is not found?
A. Reverts
B. Null
C. Zero-value of the value type β
D. Throws an error - What does keccak256() function do in Solidity?
A. Generates pseudorandom numbers
B. Encodes string to base64
C. Calculates the SHA-3 hash β
D. Performs digital signing - Which Solidity version introduced pragma ^0.8.0?
A. With overflow/underflow protections β
B. Added string slicing
C. Deprecated events
D. Introduced memory-only data - What is the default value of a boolean in Solidity?
A. 1
B. false β
C. null
D. 0x0 - Which type of variable is not stored on the blockchain?
A. public
B. memory β
C. storage
D. mapping - What does msg.value represent in a payable function?
A. The amount of tokens received
B. The senderβs balance
C. The amount of Wei sent with the call β
D. The block reward - How do you send Ether from a contract in Solidity >= 0.8.x?
A. address.transfer(amount)
B. address.send(amount)
C. payable(address).call{value: amount}(“”) β
D. address.deposit(amount) - What is an enum in Solidity?
A. A constant address
B. A data type that restricts variable to predefined values β
C. A fixed array
D. A form of hashing - Which statement is true about modifiers in Solidity?
A. Used only with fallback functions
B. Automatically handle errors
C. Reusable pre-function logic β
D. Provide event logs - What is the purpose of block.timestamp in Solidity?
A. The current time of the Ethereum network β
B. The timestamp of contract deployment
C. The hash of the block
D. Miner-provided nonce - How are constructor arguments passed during deployment?
A. Through a separate file
B. As metadata in bytecode β
C. They are ignored
D. Via fallback function - What does abi.encodePacked() return?
A. String
B. JSON
C. Bytes tightly packed β
D. Hash - What is the function of assert() in Solidity?
A. To test external conditions
B. To revert on failed internal error checks β
C. To send Ether
D. To prevent reentrancy - Which type of call is considered dangerous for reentrancy?
A. Static call
B. External function call β
C. Internal pure function
D. emit call - Which of the following Solidity types is dynamic?
A. uint256
B. address
C. bytes β
D. bool - What is the use of indexed keyword in Solidity events?
A. Allows filtering by that field β
B. Marks the field for deletion
C. Removes duplicates
D. Limits gas usage - What is OpenZeppelin used for?
A. Ethereum network setup
B. Testing token transfers
C. Standard, secure smart contract libraries β
D. Gas optimization - What does the fallback function not have?
A. A name β
B. Logic
C. An address
D. A return value - Which gas cost is higher in Ethereum?
A. Setting a variable to zero
B. Setting a new non-zero value β
C. Calling a pure function
D. Calling a view function - Which of the following causes a transaction to fail in Ethereum?
A. Reaching the block gas limit
B. Calling a non-existent address
C. Reverting inside the contract β
D. Having zero balance - What does a smart contract address depend on during deployment?
A. Deployerβs balance
B. Random nonce
C. Deployerβs address and nonce β
D. Chain ID - What is the default visibility of a function in Solidity?
A. public
B. internal β
C. private
D. external - What does memory keyword do in Solidity?
A. Saves data on-chain
B. Saves data in EVM logs
C. Temporarily stores data during function execution β
D. Encrypts a string
π Section 3: Intermediate Solidity & DApps (61β90)
- What is a fallback function in Solidity?
A. Main logic of contract
B. Default function called when no other matches β
C. Error handler
D. Token allocator - What is an event in Solidity?
A. A type of struct
B. A log on blockchain β
C. A function
D. A contract initializer - What does view modifier signify?
A. Can modify state
B. Can only call another contract
C. Reads blockchain state, cannot modify β
D. Sends ETH - Which standard is used for fungible tokens?
A. ERC-721
B. ERC-1155
C. ERC-20 β
D. ERC-1400 - What is keccak256 in Solidity?
A. A hash function β
B. Random number generator
C. Decryption algorithm
D. Compiler - Mapping in Solidity is used for?
A. Iteration
B. Database connection
C. Key-value storage β
D. Logging
π Section 3: Intermediate Solidity & DApps (continued)
- Which data type should you use for storing ETH or token balances?
A. int
B. string
C. uint256 β
D. bool - What happens if assert(false) is triggered?
A. Skips line
B. Contract continues
C. Reverts transaction and consumes all gas β
D. Logs error and exits gracefully - What is a constructor in Solidity?
A. A function that destroys a contract
B. A payable function
C. A function executed only once during contract deployment β
D. A fallback function - Which function transfers Ether safely in Solidity (0.8+)?
A. transfer()
B. send()
C. call{value: amount}(“”) β
D. sendEther() - Which of these keywords is used to define an interface in Solidity?
A. interface β
B. abstract
C. implement
D. define - What does the keyword memory mean in a function parameter?
A. Persistent storage
B. Temporary storage during execution β
C. Stack location
D. Blockchain storage - The function modifier onlyOwner is used for?
A. Checking token balance
B. Ensuring only the contract owner can call the function β
C. Verifying transactions
D. Pausing the contract - Which function is used to receive Ether in a contract?
A. receive() β
B. receiveEther()
C. getEther()
D. etherReceiver() - When should the fallback() function be defined?
A. To handle undefined function calls β
B. To transfer Ether
C. To initialize tokens
D. To manage errors - What is the visibility of a function that can be accessed internally and externally?
A. public β
B. private
C. internal
D. external - How do you return multiple values from a Solidity function?
A. Use arrays
B. Use structs
C. Use tuples β
D. Itβs not possible - The keyword emit is used for?
A. Returning gas
B. Calling a fallback
C. Triggering events β
D. Declaring errors - What is OpenZeppelin?
A. Ethereum blockchain
B. Token
C. Security library for smart contracts β
D. Solidity compiler - Which type of contract can be inherited in Solidity?
A. Constant
B. Interface
C. Abstract β
D. Static - What is a reentrancy attack?
A. Mining manipulation
B. Calling another contract recursively before state update β
C. Gas refund
D. ETH overflow - What does the keyword payable allow?
A. Receiving Ether β
B. Storing data
C. Logging transactions
D. Protecting from overflow - What is SafeMath used for?
A. Gas optimization
B. Integer overflow protection β
C. Signature validation
D. Token management - What is Remix IDE used for?
A. DApp frontend
B. Wallet manager
C. Smart contract development and testing β
D. Database management - How to prevent overflows in Solidity 0.8+?
A. Use SafeMath
B. Manual checks
C. Built-in overflow checks β
D. OverflowFixer - What is a smart contract?
A. Web server
B. Decentralized application logic on blockchain β
C. Ethereum node
D. Token - Which data type is used for true/false logic?
A. string
B. uint
C. bool β
D. bytes - Whatβs the advantage of using libraries in Solidity?
A. External debugging
B. Avoid code duplication β
C. Reduce contract size
D. Add mining features - What does msg.value represent?
A. Senderβs address
B. ETH sent with transaction β
C. Gas used
D. Recipient balance - What is the role of a smart contract ABI?
A. Bytecode
B. Compilation
C. Interface for interacting with the contract β
D. Wallet generation
β End of Quiz