Complete the code to declare a simple class named Car.
class [1] { }
The class name should start with a capital letter and match the intended name. Here, Car is the correct class name.
Complete the code to add a property color of type String inside the class.
class Vehicle { var [1]: String }
color.The property name should be color as requested, with type String.
Fix the error in the class declaration by completing the missing keyword.
[1] Car {
var model: String
}struct or func instead of class.The keyword class is required to declare a class in Swift.
Fill both blanks to declare a class Person with a method greet() that prints a greeting.
class [1] { func [2]() { print("Hello!") } }
The class name should be Person and the method name should be greet as requested.
Fill all three blanks to declare a class Animal with a property name of type String and an initializer that sets the name.
class [1] { var [2]: String init([3]: String) { self.name = [3] } }
The class name is Animal, the property is name, and the initializer parameter is also name to assign the property.