0
0
Blockchain / Solidityprogramming~10 mins

Reference types behavior in Blockchain / Solidity - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to declare a reference type variable in Solidity.

Blockchain / Solidity
string memory [1] = "hello";
Drag options to blanks, or click blank then click option'
Agreeting
Baddress
Cbool
Duint
Attempts:
3 left
💡 Hint
Common Mistakes
Using a type name instead of a variable name.
Using a value instead of a variable name.
2fill in blank
medium

Complete the code to assign a reference type variable to another in Solidity.

Blockchain / Solidity
string memory name1 = "Alice";
string memory [1] = name1;
Drag options to blanks, or click blank then click option'
Aname2
Bbool
Caddress
Duint
Attempts:
3 left
💡 Hint
Common Mistakes
Using a type name instead of a variable name.
Using the same variable name twice.
3fill in blank
hard

Fix the error in the function parameter declaration for a reference type in Solidity.

Blockchain / Solidity
function setName(string [1] newName) public {
    name = newName;
}
Drag options to blanks, or click blank then click option'
Aaddress
Buint
Cstorage
Dmemory
Attempts:
3 left
💡 Hint
Common Mistakes
Using storage instead of memory for function parameters.
Omitting the data location keyword.
4fill in blank
hard

Fill both blanks to correctly declare and assign a dynamic array reference type in Solidity.

Blockchain / Solidity
uint[] [1];
[2] = new uint[](5);
Drag options to blanks, or click blank then click option'
Anumbers
Caddress
Dbool
Attempts:
3 left
💡 Hint
Common Mistakes
Using different names for declaration and assignment.
Using invalid types for the array variable.
5fill in blank
hard

Fill all three blanks to create a mapping from address to a dynamic array of uint in Solidity.

Blockchain / Solidity
mapping([1] => [2]) public [3];
Drag options to blanks, or click blank then click option'
Aaddress
Buint[]
Cbalances
Dstring
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect types for mapping keys or values.
Using an invalid variable name for the mapping.