Book Appointment Now

Tables, Data & Networking in iOS Coursera Quiz Answers

Tables, Data & Networking in iOS Week 01 Quiz Answers

Quiz 1: Exploring Data

Q1. What are some important consideration when working with data in iOS?

  • Apps should respect the fact that mobile network bandwidth and data limits can be low
  • Apps should only ask for data when it is needed
  • Apps need to respect the fact that there could be thousands of rows of information that needs to be displayed
  • Users will need a way to easily access data

Quiz 2: Tables & Data Review

Q1. Which of the following are functions of the UITableViewDataSource protocol?

  • cellForRowAt
  • heightForHeaderInSection
  • numberOfSections
  • numberOfRows
  • didSelectRow

Q2. To get your UITableView to recycle its rows, you need to call the recycle() function

  • True
  • False

Q3. How can you create a variable that is publicly accessible, but that cannot be modified from outside the file it is declared in?

  • private(set) var title: String
  • public get private set var title: String
  • private(set) public(get) var title: String
  • readonly public var title: String

Q4. Which of the following is the correct way to change the scroll direction of a UICollectionView to horizontal?

1.
var collection = UICollectionView()
  if let layout = collection.collectionViewLayout as? UICollectionViewFlowLayout {
     layout.scrollDirection = .horizontal
}
2.
var collection = UICollectionView()
collection.direction = .horizontal
3.
var collection = UICollectionView()
collection.layout.scrollDirection = .horizontal

4. All of the above will work

Q5. If the items in the data source that your UITableView is using is altered or updated, what do you need to do to reflect those changes in the UITableView user interface?

  • You must reset your table view’s delegate
  • Call the function reloadData() on your table
  • Call the function setNeedsDisplay() on your view controller
  • Call the function refreshData() on your table

Quiz 1: Final Review

Q1. Name one of the two required protocols you must implement when working with UITableView?

Enter answer here

Q2. What class can you inherit from that will automatically implement the protocols needed for UITableView?

Enter answer here

Q3. What class does UITableView inherit from?

Enter answer here

Q4. What class must you inherit from to create cells for a UITableView?

Enter answer here

Q5. How do you reuse table view cells for your table view?

  • Call dequeueReusableCell on UITableView
  • Call unloadEmptyCell on UITableView
  • Simply create a new table view cell, it will grab an unused cell automatically
  • None of the above

Q6. Where do you tell UITableView how many cells you will need?

  • numberOfCellsPerSection
  • rowsNeededPerSection
  • totalRowsForSection
  • numberOfRowsInSection

Q7. Which of these functions are part of the UITableViewDelegate protocol?

  • heightForRow
  • cellForRowAt
  • willDisplay
  • viewForHeaderInSection

Q8. What must you do to any UITableViewCell before you can dequeue them for reuse?

  • Add each class to the Info.plist file
  • Assign them a unique cell identifier
  • You must enable them by setting the property isEnabled on the cell
  • You must register them within the protocol function registerCell

Q9. Before your UITableView protocol functions are called, what must you do first?

  • Set the direction property of the table view
  • Set the dataSource property of the table view
  • Set the delegate property of the table view
  • Set the totalRows property of the table view

Q10. You can remove the separator line that is shown between table cells?

  • True
  • False

Tables, Data & Networking in iOS Week 02 Quiz Answers

Quiz 1: Core Data Preamble

Q1. What are some good use cases for implementing Core Data in your iOS app?

  • When you want data to be stored even after your app closes
  • When a stable network connection is not guaranteed
  • When you are working with complex data sets
  • When you need high performance data saving and fetching

Quiz 2: Core Data Quick Review

Q1. To save an object to Core Data what must you do?

  • Make your data changes, then call save() on the managed object context
  • Call the saveAll() function on the persistent container
  • Your data changes are automatically saved as they are made
  • None of the above

Quiz 3: Final Review

Q1. Can the persistent store coordinator have multiple persistent stores?

  • Yes
  • No

Q2. How many managed object models can a persistent store coordinator have?

Enter answer here

Q3. Where do you create Core Data entities and relationships?

  • In the Info.plist file
  • In the xcdatamodeld file
  • In any struct that inherits from the CoreData protocol
  • Any of the options above will work

Q4. How can you retrieve data from Core Data?

  • By calling find on an NSFetchRequest
  • By calling retrieve on the NSPersistentStore
  • By calling find on the NSPersistentStore
  • By calling fetch on the NSManagedObjectContext

Q5. An Entity can inherit from another Entity?

  • True
  • False

Q6. Properties that you define as part of the model, but that are not saved to the persistent store as part of an entity instance’s data are known as?

Enter answer here

Q7. Which of the following are valid Core Data attribute types?

  • NSString
  • NSNumber
  • NSDate
  • NSMutableArray

Q8. The Core Data stack consists of what primary objects?

  • NSManagedObjectContext
  • NSPersistentStoreCoordinator
  • NSPersistentCoordinator
  • NSFetchedResultsController
  • NSManagedObjectModel

Q9. To create a subclass for an entity in code, you must inherit from what class?

  • NSManagedObject
  • NSObject
  • NSFetchRequest
  • NSEntityModel

Q10. What class would you use to filter fetched results from Core Data?

Enter answer here

Tables, Data & Networking in iOS Week 03 Quiz Answers

Quiz 1: Quick Review

Q1. What does HTTP stand for?

Enter answer here

Quiz 2: Swift Refresher

Q1. Given the code below, what will be printed?

1. let number = 5

2. 
3. switch number {
4. case 0..<5:
5.  print("A")
6. case 5...10:
7.     print("B")
8. case 0...5:
9.     print("C")
10. default:
11.  print("D")
12.  }
  • A
  • B
  • C
  • D

Q2. Given the code below, what will be printed?

1. func display(names: String...) {
2.    print("Friends:", names.joined(separator: ", "))
3. }

4. 
5. display(names: "Tom", "Larry", "Moe")
  • Friends: Tom, Larry, Moe
  • Friends: TomLarryMoe
  • Friends: ,Tom, Larry, Moe,
  • The code will not compile

Q3. Given the code below, what will be printed?

1. var people = Dictionary<String,String>()
2. people["Bob"] = "Smith"
3. print(people.count)
  • 0
  • 1
  • This code will compile, but will print nothing at runtime
  • This code will not compile

Q4. When the code below runs, what will the value of the result constant be?

1. func sum(numbers: Array<Int>) -> Int {
2.    var result = 0

3.
4.    for number in numbers {
5.        result += number
6.   }

7.
8.    return result
9. }

10.
11. let result = sum(numbers: [5, 4, 3, 2, 1])
Enter answer here

Q5. When the code below is run, what will be printed?

1.let card = "Aces"

2.
3.switch card {
4.case "Aces":
5.    fallthrough

6.
7.case "Spades", "Clovers", "Hearts":
8.    print("Spades Clovers Hearts")

9.
10.default:
11.    print("No Card")
12.}
Enter answer here

Q6. When the code below runs, what will the value of the result constant be?

1. let numbers = [1, 3, 5, 7, 9]
2. let result = numbers.map { $0 * 10 }
  • [1,3,5,7,9]
  • [10,30,50,70,90]
  • [0]
  • This code will not compile

Q7. Given the code below, what value will be printed?

1. let digits = Array(1..<10)
2. print(digits.count)
Enter answer here

Q8. Given the code below, what value will be printed?

1. let countries = [String](repeating: "Belgium", count: 2)
2. print(countries.count)
Enter answer here

Q9. Given the code below, what value will be printed?

1. var cars = Set()
2. cars.insert("Volvo")
3. cars.insert("Mercedes")
4. cars.insert("Ford")
5. cars.insert("Volvo")
6. print(cars.count)
Enter answer here

Q10. Given the code below, what value will be printed?

1. var trees = [String]()
2. trees.reserveCapacity(2)
3. trees.append("Oak")
4. trees.append("Redwood")
5. trees.append("Evergreen")
6. print(trees.count)
Enter answer here

Tables, Data & Networking in iOS Week 04 Quiz Answers

Quiz 1: Networking Review

Q1. What does the acronym CRUD stand for?

  • Create, Read, Update, Delete
  • Creation, Replication, Universal, Derivative
  • Casting, Replication, Universal, Derivative
  • None of the above

Q2. What does REST stand for?

Enter answer here

Q3. What is the best and quickest way to parse JSON from the network?

  • Use Swift’s JSONSerialization class
  • Implement the Codable or Encodable protocol on your data model
  • Use XML instead of JSON
  • None of the above

Q4. What do you need to do in your iOS app in order to allow insecure network requests?

  • Register the insecure domains you wish to use on https://developer.apple.com
  • In App Transport Security Settings you can add insecure “Exception Domains”
  • In App Transport Security Settings you can “Allow Arbitrary Loads”
  • As of iOS 10 you can no longer make insecure network requests

Q5. Network requests on iOS should always be:

  • Asynchronous
  • Synchronous

Q6. Because network requests can fail, you must always:

  • Check for 404 and 403 status codes
  • Parse the message field of the incoming error
  • Retry the request if it fails
  • Request status codes and errors are determined by the API and you must therefore match what the API sends

Q7. Which of the following are usually the headers that you will need to send up with a network request?

  • “Client” : “POST”
  • “Security” : “HTTP/HTTPS”
  • “Content-Type” : “application/json”
  • “Accept” : “application/json”

Q8. To get back on the UI thread after an asynchronous request is made you must call what function?

Enter answer here

Q9. Which status code typically represents success?

Enter answer here

Q10. What is the primary difference between a GET request and a POST request?

  • A POST request can only be made against secure (HTTPS) endpoints
  • A GET request is for creating new objects while POST is for fetching existing objects
  • A POST request often has a body while a GET request does not
  • A GET request is just another name for a POST request
Get all Course Quiz Answers of Swift 5 iOS Application Developer Specialization

Introduction to Programming in Swift 5 Coursera Quiz Answers

Introduction to iOS App Development with Swift 5 Quiz Answers

Tables, Data & Networking in iOS Coursera Quiz Answers

iOS App Store & In-App Purchases Coursera Quiz Answers

Share your love

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Leave a Reply

Your email address will not be published. Required fields are marked *