Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Could someone please help me answer some Swift programming questions? Thanks, I will thumbs up. When a Double is initialized with a String a failable

Could someone please help me answer some Swift programming questions? Thanks, I will thumbs up.

When a Double is initialized with a String a failable initializer is called. What type is value in the following line of Swift code?

var value = Double("51.38")

Double
Double!
Double?
String
String?

Void

Question 13

Given the following Swift function:

func find(pattern: String, in info: String) -> Int? { // code }

Which of the following is the correct way to call the function?

let position = find(pattern: "Sally", in: "People talked with Sally in the park.")
let position = find(pattern: "Sally", info: "People talked with Sally in the park.")

let position = find(pattern: "Sally", in info: "People talked with Sally in the park.")

let position = find("Sally", "People talked with Sally in the park.")

Question 14

Given the following Swift function:

func find(pattern: String, in info: String) -> Int? { // code }

What name is used to access the second parameter's value from within the function?

pattern
in
info
String

Question 28

The === operator in Swift is used to do which of the following?

To test if two variables hold the same value.
To test if two variables refer to the same instance of a class.
To test if two instances have the same methods.
To test if a type and optional type refer to the same value.

Question 29

Given: struct Circle { var x = 0.0, y = 0.0, width = 0.0 } var circle = Circle()

Which of the following is used to set the width property of circle to 10.0 in Swift?

circle["width"] = 10.0
circle.setWidth(10.0)
circle.width = 10.0
circle->width = 10.0

Question 30

Given:

struct Circle { var x = 0.0, y = 0.0, width = 0.0 } let circle = Circle()

Is the following allowed?

circle.x = 12.3

Yes
No

Question 35

Structure instances are always passed by value and class instances are always passed by reference in Swift.

True
False

Question 36

What are functions defined in a class called?

activities
characteristics
methods
optionals
properties

Question 37

In Swift, what is a computed property in a class?

A method called on an object that changes a property.
A property based on a calculation or logic when it is set or retrieved.
A property contained in a constant or variable.
All properties are computed properties in Swift.

Question 38

What is a way in Swift to add initializers, computed properties, methods, and subscripts to an existing class without needing to create a subclass or edit the existing class?

class alias
extensions
partial class definitions
protocols

Question 39

Which kind of inheritance does Swift support for classes?

multiple inheritance
single inheritance

Question 40

Which kind of Swift collection is represented in the code below?

var measurement: [String: Double] = ["pressure": 21.4, "temperature": 374.3, "volume": 41.2]

Array
Dictionary
Set

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems An Application Oriented Approach Complete Version

Authors: Michael Kifer, Arthur Bernstein, Richard Lewis

2nd Edition

0321268458, 978-0321268457

More Books

Students also viewed these Databases questions

Question

Explain the function and purpose of the Job Level Table.

Answered: 1 week ago