Properties in Swift coding

Quiz
•
Computers
•
University
•
Medium
Harold Peaden
Used 4+ times
FREE Resource
18 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Here is a link to the Google doc I copied from Apple's documentation for teaching this subject before students take this quiz:
https://docs.google.com/document/d/1PU7b5Y7A7QeeccukmfxwVeyo5z7IM1dyFX-NKbZZLqA/edit?usp=sharing
I understand
I don't understand
2.
MULTIPLE CHOICE QUESTION
30 sec • 5 pts
What is the primary purpose of properties in Swift?
A. To store values globally.
B. To associate values with a particular class, structure, or enumeration.
C. To execute functions inside an instance.
D. To monitor memory usage of an instance.
Answer explanation
Correct Answer: B
Explanation: Properties associate values with specific instances of a class, structure, or enumeration.
3.
MULTIPLE CHOICE QUESTION
30 sec • 6 pts
Which types of properties are provided by classes and structures in Swift?
A. Stored and computed properties.
B. Computed properties only.
C. Stored properties only.
D. None of the above.
Answer explanation
Correct Answer: A
Explanation: Both stored and computed properties are provided by classes and structures.
4.
MULTIPLE CHOICE QUESTION
30 sec • 5 pts
Can enumerations in Swift have stored properties?
A. Yes, always.
B. No, enumerations can only have computed properties.
C. Yes, but only with property observers.
D. No, enumerations cannot have properties.
Answer explanation
Correct Answer: B
Explanation: Enumerations in Swift can only have computed properties, not stored ones.
5.
MULTIPLE CHOICE QUESTION
30 sec • 6 pts
On which types of properties can property observers be added?
A. Only stored properties defined by the user.
B. Only computed properties.
C. Both stored and computed properties.
D. Only inherited properties in a subclass.
Answer explanation
Correct Answer: A
Explanation: Property observers can be added to stored properties defined by the user or inherited from a superclass.
6.
MULTIPLE CHOICE QUESTION
30 sec • 6 pts
What are type properties in Swift?
A. Properties that calculate values for specific instances.
B. Properties shared across all instances of a type.
C. Properties that store values for enumerations.
D. Properties associated with functions.
Answer explanation
Correct Answer: B
Explanation: Type properties are shared by all instances of a type and are associated with the type itself.
7.
MULTIPLE CHOICE QUESTION
30 sec • 5 pts
What is the primary difference between stored properties and computed properties?
a) Stored properties calculate their value, while computed properties store it.
b) Stored properties store a value, while computed properties calculate it.
c) Both stored and computed properties are only provided by classes.
d) Stored properties and computed properties are always constant.
Answer explanation
Correct Answer: b
Explanation: Stored properties save a constant or variable value, while computed properties dynamically calculate their value using a getter and (optionally) a setter.
Create a free account and access millions of resources
Similar Resources on Wayground
14 questions
OOP Introduction

Quiz
•
12th Grade - University
20 questions
STM 2013 : FORMATIF T3-FORM & REPORT

Quiz
•
University
15 questions
Introduction of Flash

Quiz
•
12th Grade - University
15 questions
Microsoft Excel Functions

Quiz
•
University
20 questions
1Mx-Review Quiz

Quiz
•
9th Grade - University
21 questions
COMPUTER ETHICS

Quiz
•
University
15 questions
Logo Creation in Photopea

Quiz
•
7th Grade - University
19 questions
Requirements Engineering @TUM repetition

Quiz
•
University
Popular Resources on Wayground
10 questions
Video Games

Quiz
•
6th - 12th Grade
10 questions
Lab Safety Procedures and Guidelines

Interactive video
•
6th - 10th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
10 questions
UPDATED FOREST Kindness 9-22

Lesson
•
9th - 12th Grade
22 questions
Adding Integers

Quiz
•
6th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
20 questions
US Constitution Quiz

Quiz
•
11th Grade
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade
Discover more resources for Computers
10 questions
Would you rather...

Quiz
•
KG - University
20 questions
Definite and Indefinite Articles in Spanish (Avancemos)

Quiz
•
8th Grade - University
7 questions
Force and Motion

Interactive video
•
4th Grade - University
10 questions
The Constitution, the Articles, and Federalism Crash Course US History

Interactive video
•
11th Grade - University
7 questions
Figurative Language: Idioms, Similes, and Metaphors

Interactive video
•
4th Grade - University
20 questions
Levels of Measurements

Quiz
•
11th Grade - University
16 questions
Water Modeling Activity

Lesson
•
11th Grade - University
10 questions
ACT English prep

Quiz
•
9th Grade - University