Blockchain CBDE Practice Test - Questions Answers, Page 5
List of questions
Related questions
Solidity files:
A.
can't be split across multiple files, everything should be in one single file.
B.
can be split across multiple files, but every contract must be in a file with the same name as the contract itself.
C.
can be spread across multiple files. To import all contract from a file you can use "import 'myfile.sol'. To import Contract MyContract from myfile.sol you use "import {MyContract as SomeContract} from 'myfile.sol';".
Files can be imported:
A.
using relative and absolute paths, where the "." And the ".." depict that it's a relative path.
B.
only via GitHub using the Repository and Username.
C.
using the special requirefile(...) statement, which looks in a specific library path to import files.
Importing from GitHub:
A.
works across all compilers and platforms the same way.
B.
is generally possible, but currently works only in Remix, but doesn't work in Truffle.
Single line comments in Solidity are:
A.
working with either // or ///
B.
working with /* comment */ or /** @.. natspec style */
C.
not possible, all comments must be multi-line.
Multi-Line Comments in Solidity are:
A.
working with either // or ///
B.
working with /* comment */ or /** @.. natspec style */
C.
not possible, all comments must be single-line.
The following are value types in Solidity.
A.
Integer, Boolean, Struct, Mapping and Enum.
B.
Integer, Boolean, Enum and Addresses.
C.
Integer, Boolean, Structs and Fixed Point Numbers.
To compare a String in Solidity you use:
A.
string1 == string2
B.
the internal function "str_compare(str1,str2)"
C.
you can't directly compare two strings, but one method would be to hash both strings and compare the hashes.
D.
bytes32(string1) == bytes32(string2)
If we divide two integers:
5/2, the result is:
A.
2, because the decimal is truncated.
B.
3, because it's always rounded.
C.
2.5, because it's automatically converted into a float.
A
Struct is a great way:
A.
to define a new datatype in Solidity, so you don't need to use objects of another contract.
B.
to hold instances of other contracts.
C.
to implement pointers to other contracts that can hold new datatypes.
A Mapping consists of keys and value.
A.
the Keys can be anything, but the value can't be another mapping or struct.
B.
the Value can be anything, but the key cannot be another mapping, struct, integer or Boolean.
C.
the value can be anything, but the key cannot be another mapping, struct, enum or dynamically sized array.
Question