Dive into Swift Fundamentals to strengthen your programming foundation. Learn about variables, constants, data types, type inference, type safety, and code documentation with clarity and precision.
let keyword signify in Swift?
var keywordvar age: Int = 25age = Int: 25Int var age = 25let Int age = 2542 be inferred as in Swift?
FloatDoubleFloat or DoubleIntFloat and Double in Swift?
Double has higher precision than FloatFloat can store larger numbers than DoubleFloat is immutable while Double is mutabletrue in Swift?
var name: String = "John"let name: StringInt value to a Float variableString value to an Int variableBool value to a Character variable/// comment syntax signify in Swift?
//print("Variable value: \(variable)")println(variable)echo variableprint(variable)nullAnswer Key
| Qno | Answer |
|---|---|
| 1 | a) var |
| 2 | b) A constant that cannot be reassigned |
| 3 | b) let name = “Swift” |
| 4 | c) It causes a compile-time error |
| 5 | b) Variables are declared using the var keyword |
| 6 | a) var age: Int = 25 |
| 7 | c) Int |
| 8 | b) Bool |
| 9 | c) As either Float or Double |
| 10 | a) Double has higher precision than Float |
| 11 | a) Bool |
| 12 | c) Character |
| 13 | a) Automatically determining the type of a variable |
| 14 | c) Swift ensures type safety during compile-time |
| 15 | c) Both a and b |
| 16 | d) All of the above |
| 17 | a) It avoids type-related runtime crashes |
| 18 | b) Double |
| 19 | c) // Comment |
| 20 | a) /* Comment */ |
| 21 | b) To document code and improve readability |
| 22 | b) It is used for documentation comments |
| 23 | a) It improves code readability and maintainability |
| 24 | d) Both b and c |
| 25 | c) let |
| 26 | a) print("Variable value: \(variable)") |
| 27 | b) It is static and strongly typed |
| 28 | b) It throws a compile-time error |
| 29 | b) It causes a compile-time error |
| 30 | a) Function |