SwiftUI Test 2

0%

What will the numbers constant contain when this code is run?

Correct! Wrong!

Explanation:
The code runs through all of the numbers in the array and creates a new array for each one that includes the same number twice. As a result, 1 will become [1, 1], and so on.

Integers are stored in how many bits?

Correct! Wrong!

Explanation:
On 32-bit devices, such as the iPhone 5 and older, Swift's integers are 32-bit, and 64-bit on 64-bit devices, such as the iPhone 5s and beyond.

What will the code below yield as a result?

Correct! Wrong!

Explanation:
stride() is handy for traversing a set of numbers. It will count from 1 through (but not including) 17 in this case, incrementing by four each time.

Which of the following methods for creating a raw string in Swift is correct?

Correct! Wrong!

Explanation:
Swift's raw strings have the same number of # symbols at the beginning and end, making it easier to utilize quote marks and backslashes.

What data type will be allocated to result in the code below?

Correct! Wrong!

Explanation:
The UInt8.addingReportingOverflow() method returns a tuple (UInt8, Bool) that contains the result of the add operation as well as if an overflow occurred.

What will the numbers constant contain when this code is run?

Correct! Wrong!

Explanation:
A call to map code loops through the numbers array, creating a new array for each number that includes the same number twice. As a result, 1 will become [1, 1], and so on. We're using flatMap in this case, which flattens the resulting array of arrays into a single array, transforming [[1, 1]] into [1, 1], and so on.

What is the output of the following code?

Correct! Wrong!

Explanation:
This code assigns the welcome() method to the greetCopy constant, allowing you to use greetCopy() in the same way you would greet() ().

What will the code below yield as a result?

Correct! Wrong!

Explanation:
Despite the fact that we declared the NSMutableDictionary to be constant, it is a reference type that will gladly mutate regardless of its ostensibly "constant" status. As a result, this code will return 1 because the value was correctly added.

What data type does convertedNumber have when this code is run?

Correct! Wrong!

Explanation:
If the text doesn't contain a valid number, creating an integer from it will fail. So, this constructor gives you an Int value? to offer you a number (if you're successful) or a zero (if you're unsuccessful) (on failure.)

Premium Tests $49/mo
FREE April-2024