please help with these swift question i will thumbs up in rating !!!!!! 1. Varia
ID: 3910719 • Letter: P
Question
please help with these swift question
i will thumbs up in rating !!!!!!
1. Variables price and weight are declared as implicitly unwrapped Float optionals.
Is it safe to do the following?
let cost = price * weight
A. Yes
B. No
2. Which if the following is the declaration of a Float optional that is not implicitly unwrapped?
A. var length: Float = 12.5
B. var length: Float! = 12.5
C. var length: Float? = 12.5
D. var length = 12.5
3. All variables and constants declared in Swift must have their types explicitly declared.
A. True
B. False
4. Is it possible in Swift to group case matches together with a common set of statements to be executed when a match for any of the cases is found. For example, is the following allowed?
case 3, 5, 7:
// code for case
A. Yes
B. No
5. Which of the following is correct if no argument label is to be specified when calling a Swift function?
A. Specify no argument label in the function declaration.
B. Make the argument label and the parameter name the same in the function declaration.
C. Use _ as the argument label in the function declaration.
D. An error will be generated at compile time.
Explanation / Answer
Answer 1:No, it might lead to fatal errors at runtime
Answer 2:
Float! which it indicates it allows no value
Answer 3:False, we dont need declare the type just we can declare with keyword var
Answer 4: Yes we can have multiple values for case labels
Answer 5: C, use _ as the argument, it will ignore the label names
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.