Exercises
Build confidence in Swift programming fundamentals with this beginner-friendly quiz. Test your knowledge of Swift file types, variable and constant declarations, printing output, defining functions, value types, string concatenation, error handling, control flow statements, and optional types. Whether you are preparing to develop iOS apps or reviewing the core Swift language syntax, these questions provide a quick way to check your understanding of essential concepts.
Answer the questions below and check the explanation for each answer.
0/10 answered
Auto audio on: the next questions will be read aloud when you click Continue.
The main file type used for Swift code is .swift. Swift is a programming language developed by Apple Inc. specifically for iOS and macOS development.
The keyword used to define a variable in Swift is var. It allows you to create variables that can change their value.
The correct way to declare a constant in Swift is by using the keyword let. Constants are defined with a value that cannot change.
In Swift, the print() function is used to print messages to the console.
To define a function in Swift, use the keyword func followed by the function name and parentheses. The function body is enclosed in curly braces.
In Swift, there is no keyword for a default 'value' type, as it infers type from the assigned value. Each variable or constant is defined with a specific data type based on its initial value.
The + symbol is used for string concatenation in Swift, allowing you to combine strings together.
The do-catch keyword is used to handle errors in Swift. The 'do' block contains the code that can throw an error, and the 'catch' block handles the error.
The switch statement is a control flow statement in Swift used to perform certain actions based on different conditions.
In Swift, you declare an optional type using the datatype followed by a ?, indicating that the variable or constant can either have a value or be nil.

Free CourseDart and Flutter Developer course
20h47m
6 exercises

Free CourseFlutter for complete beginners
1h45m
6 exercises

Free CourseLearn Flutter and Dart to create apps
2h48m
25 exercises

Free CourseBuild Your First Universal React Native App
1h23m
9 exercises

Free CourseAndroid for beginners
10h47m
52 exercises

Free CourseIonic for Beginners
5h04m
22 exercises

Free CourseFlutter tutorial for beginners
4h23m
8 exercises

Free CourseiOS
22h35m
13 exercises
Thousands of online courses in video, ebooks and audiobooks.
To test your knowledge during online courses
Generated directly from your cell phone's photo gallery and sent to your email
Download our app via QR Code or the links below:.
+ 10 million
students
Free and Valid
Certificate
60 thousand free
exercises
4.8/5 rating in
app stores
Free courses in
video and ebooks