Answered step by step
Verified Expert Solution
Question
1 Approved Answer
undefined Question 5 5 pts Given the following in Swift: struct Kilometers { var kilometers: Double init(from Miles miles: Double) { kilometers = miles *
undefined
Question 5 5 pts Given the following in Swift: struct Kilometers { var kilometers: Double init(from Miles miles: Double) { kilometers = miles * 1.60934 } init(from Meters meters: Double) { kilometers = meters / 1000.0 } } Which of the following is the correct way to create an instance of the struct if the known distance is in miles? let distance = Kilometers(from Miles: 2.5) let distance = Kilometers(miles: 2.5) let distance = new Kilometers(from Miles: 2.5) Olet distance = new Kilometers(miles: 2.5) let distance =Kilometers(2.5 as miles) Given: struct Circle { var radius = 0.0 var x = 0.0 var y = 0.0 } Which of the following is the correct line of Swift code for creating an instance of a Circle with a radius of 5.0 and a position of x = 2.3 and y = 7.1? let circle = new Circle(5.0, 2.3, 7.1) let circle = new Circle(radius: 5.0, x: 2.3, y: 7.1) let circle = Circle(5.0, 2.3, 7.1) let circle = Circle(radius: 5.0, x: 2.3, y: 7.1) Question 12 5 pts Objects are comprised of data variables and functions. The data variables and functions are referred to as class members. Which of the following is the name used for data variables in an object? methods O optionals O properties O characteristics Question 13 5 pts Which of the following is the correct way in Swift to define a class Dog that inherits from Pet? class Dog extends Pet { } class Dog, Pet class Dog : Pet {} class Dog as Pet { } Question 18 5 pts Given: struct Size { var width = 0.0, height = 0.0 } let size1 = Size() Is the following allowed? size1.width = 12.4 No Yes Question 19 5 pts Given: struct Point { var x = 0.0, y = 0.0 } var point1 = Point() Which of the following is used to set the x property of point1 to 7.1 in Swift? point1->x = 7.1 point1.x = 7.1 point1.setX(7.1) point1["x"] = 7.1 Question 20 5 pts In order to make any changes made to a parameter persist after a function has returned, the parameter must be declared using the keyword. Parameters passed to a function that are declared without the keyword cannot have their values changed by the functionStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started