Contract-level global variables can have a visibility modifier attached to them. It is important to understand that state data can be viewed across the entire network irrespective of the visibility modifier. The following state variables can only be modified using functions:

public : These state variables are accessible directly from external calls. A getter function is implicitly generated by the compiler to read the value of public state variables.

internal : These state variables are not accessible directly from external calls. They are accessible from functions within a current contract and child contracts deriving from it.

private : These state variables are not accessible directly from external calls. They are also not accessible from functions from child contracts. They are only accessible from functions within the current contract.

4. What is Variable Hoisting in Solidity?

Hoisting a concept is where variables need not be declared and initialized before using the variable. The variable declaration can happen at any place within a function, even after using it. This is known as variable hoisting.





The Solidity compiler extracts all variables declared anywhere within a function and places them at the top or beginning of a function and we all know that declaring a variable in Solidity also initializes them with their respective default values. This ensures that the variables are available throughout the function.





5. What are the different cryptographic functions supported in Solidity?

Solidity provides cryptographic functions for hashing values within contract functions. There are two hashing functions—SHA2 and SHA3. The sha3 function converts the input into a hash based on the sha3 algorithm while sha256 converts the input into a hash based on the sha2 algorithm. There is another function, keccak256, which is an alias of the SHA3 algorithm. However, i t is recommended to use the keccak256 or sha3 functions for hashing needs.



6. Is it a valid syntax in Solidity Programming?



if (1) { ... }

There is no type conversion from non-boolean to boolean types as there is in C and JavaScript, so if (1) { ... } is not valid in Solidity.





