
Apple Swift Development II - Unit 3 - Vocats Test
Computers
9th - 12th Grade
Used 8+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
22 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
If a variable can be set to any given structure, what is the variable’s type?
Any
as
anyObject
is
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
When is it appropriate to use the as! Operator?
When you need to convert a value to an Any type
When you need to downcast from one type to another, on the condition that the type is valid
When you need to downcast from one type to another and you can guarantee the type is valid
When you need to unwrap an optional
3.
MULTIPLE SELECT QUESTION
30 sec • 1 pt
When you conditionally downcast from one type to another and store the value in a constant, which combination of keywords is used? Select all that apply.
as!
as?
if let
is
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the result of the following block of code?
let sum = 99
func computSum(scores: [Int]) -> Int {
var sum = 0
for score in scores {
sum += score
}
return sum
}
computeSum(scores: [70, 30, 9])
0
00
109
Compiler error; sum cannot be defined twice in the same scope
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the result of the following block of code?
let sum = 99
func computeSum(scores: [Int]) -> Int {
var sum = 0
for score in scores {
sum += score
}
return sum
}
let sum = computeSum(scores: [70, 30, 9])
0
99
109
Compiler error; sum cannot be defined twice in the same scope
6.
MULTIPLE SELECT QUESTION
30 sec • 1 pt
Why is self in front of the property names of the initializer? Check all that apply.
struct ThemePark {
var name: String
var numEmployees: Int
var mostPopularRide: String
init(name: String, numEmployees: Int, mostPopularRide:
String) {
self.name = name
self.numEmployees = numEmployees
self.mostPopularRide = mostPopularRide
}
}
It helps the reader distinguish between the parameters and properties with the same name
self is always required when setting properties with an initializer
It helps Swift compiler distinguish between the parameters and properties with the same name.
self is not required
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What property would you modify if you wanted to add a badge to a tab?
badge
badgelcon
badgeString
badgeValue
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?