You have a request ? Contact Us Join Us

Working with Data

Coursera: Meta React Native Specialization. Module quiz: REST APIs, Interacting with REST APIs in React Native, Databases & SQL.


Module quiz: REST APIs

1. Special characters like | or ^ are recommended when defining your endpoints to improve security. True or false?
  • True 
  • False 
2. When designing your API, you should always perform data filtering using a query string, such as in the following endpoint: 
/users/{userId}/locations?country=USA
True or false?
  • True 
  • False 
3. Which of the following statements describe differences between HTTP PUT and PATCH methods? Select all that apply:
  • A PUT request can deal with multiple resources.
  • A PATCH request deals with a single record.
  • A PUT call replaces the complete resource, while the PATCH call only updates some parts.
4. Authentication and authorization are the same thing. True or false?
  • True 
  • False 
5. Which of the following HTTP status codes are used to indicate client side and server side errors? Choose all that apply:
  • 404 Not found 
  • 403 - Forbidden 
  • 301 - Moved permanently 
  • 201 - Created 
  • 503 - Service unavailable 
6. Which of the following are valid Accept headers for requesting XML content? Choose all that apply:
  • application/xml
  • code/xml
  • text/xml
  • application/x xml
  • application/xml content
7. What’s the semantic meaning of the 403 status code?
  • Bad request
  • Unauthorized
  • Forbidden
8. Which of the following statements are valid for Insomnia? Choose all that apply. 
  • Insomnia has a mobile client 
  • Insomnia can send different types of payloads 
  • Insomnia is cross platform 
  • It’s a REST API Client 
  • Insomnia has a command line tool 
9. Which of the following API clients/tools has both web and desktop versions? 
  • Curl
  • Postman
  • Insomnia
10. When trying to return the requested resource from a server via a GET HTTP call, the server returns a 404 if the resource is not found. True or false?
  • True 
  • False  

Module quiz: Interacting with REST APIs in React Native

1. Study the code below.
console.log(JSON.stringify({ 
  name: 'Meta User', 
  email: 'mataUser@example.com', 
  password: 'abc123$', 
})); 
   Which one of the following options represents what is displayed on the console?
  • '{"name":"Meta User","email":"mataUser@example.com","password":"abc123$"}'
  • Undefined

  •   name: 'Meta User', 
      email: 'mataUser@example.com', 
      password: 'abc123$',
2. Study the code below.
const json = '{"answered":true, "count":20}'; 
const obj = JSON.parse(json); 
 
console.log(obj.count); 
Which one of the following options represents what will be displayed on the console?
  • true, 20
  • 20
  • true
3. Which of the following methods is used to convert a valid JSON object into a JSON string?
  • JSON.stringify()
  • Strings and JSON object are of the same data type, and do not have to be converted.
  • JSON.parse()
4. Which one of the following code snippets demonstrates a valid JSON?
  "menu": { 
    { 
      "title": "Spinach Artichoke Dip", 
      "price": "10" 
    }, 
    { 
      "title": "Hummus", 
      "price": "10" 
    }, 
    { 
      "title": "Fried Calamari Rings", 
      "price": "51" 
    }, 
    { 
      "title": "Fried Mushroom", 
      "price": "12" 
    }, 
    { 
      "title": "Greek", 
      "price": "7" 
    }, 
    { 
      "title": "Caesar", 
      "price": "7" 
    }, 
    { 
      "title": "Tuna Salad", 
      "price": "10" 
    } 
  } 

  "menu": [ 
    { 
      "title": "Spinach Artichoke Dip", 
      "price": "10" 
    }, 
    { 
      "title": "Hummus", 
      "price": "10" 
    }, 
    { 
      "title": "Fried Calamari Rings", 
      "price": "51" 
    }, 
    { 
      "title": "Fried Mushroom", 
      "price": "12" 
    }, 
    { 
      "title": "Greek", 
      "price": "7" 
    }, 
    { 
      "title": "Caesar", 
      "price": "7" 
    }, 
    { 
      "title": "Tuna Salad", 
      "price": "10" 
    } 
  ] 

  menu: [ 
    { 
      "title": "Spinach Artichoke Dip", 
      "price": "10" 
    }, 
    { 
      "title": "Hummus", 
      "price": "10" 
    }, 
    { 
      "title": "Fried Calamari Rings", 
      "price": "51" 
    }, 
    { 
      "title": "Fried Mushroom", 
      "price": "12" 
    }, 
    { 
      "title": "Greek", 
      "price": "7" 
    }, 
    { 
      "title": "Caesar", 
      "price": "7" 
    }, 
    { 
      "title": "Tuna Salad", 
      "price": "10" 
    } 
  ] 
5. JSON is language dependent and designed to work only with JavaScript.  True or false?
  • False
  • True
6. Which of the following code snippets would you use to fetch and render images from the network in React Native?
  • <Image source={'https://reactjs.org/logo-og.png'}/>
  • <Image source={{uri: 'https://reactjs.org/logo-og.png'}} 
            style={{width: 400, height: 400}} /> 
  • <Image source={{uri: 'https://reactjs.org/logo-og.png'}}/>
7. HTTP calls to the server from React Native are asynchronous calls. True or false?
  • True
  • False
8. Observe the code below. Which request method is used by the fetch call?
const response = await fetch('https://raw.githubusercontent.com/Meta-Mobile-Developer-PC/Working-With-  Data-API/main/menu-items-by-category.json'); 
  • PUT
  • POST
  • GET
9. While making a POST request with details from the user to a server, which property is used within the fetch method to pass the request method? 
  • headers
  • body
  • method
10. Which of the following statements about JSON syntax are true? Select all that apply:
  • Objects are separated by enclosing each one in square brackets.
  • Elements in an array are separated with commas.
  • Names and values are separated with a colon.

Module quiz: Introduction to Databases & SQL

1. The following SQL statement creates a table named staff within a database: 
CREATE staff TABLE
True or false?
  • False
  • True
2. The following SQL statement creates a table named staff, with two columns called name and address: 
CREATE TABLE staff (name VARCHAR(100), address VARCHAR(100));
True or false?
  • True
  • False
3. What is the SQL command to add a new record of data in the staff table?
  • INSERT TO staff
  • ADD INTO staff
  • INSERT INTO staff
4. Which is the right command syntax to update records in the staff table in SQL?
  • UPDATE Table staff
  • Table staff UPDATE
  • UPDATE staff
5. The EDIT command is used to modify data in a database table. True or false?
  • True
  • False
6. Which one of the following SQL statements updates the email address for the individual named Karl in the staff table? 
  • UPDATE staff SET email = 'Karl@email.com' WHERE ID = 16;
  • UPDATE students SET name = 'Karl@email.com' WITH ID = 16;
  • UPDATE staff WHERE ID = 16 SET email = 'Karl@email.com';
7. Select the right keyword to complete the missing part of the following statement:  
INSERT INTO staff (ID, name) ... (7, “Tom”)
  • COLUMN
  • DATA
  • VALUES
8. A staff table consists of three columns called name, email and age. Which of the following SQL statements selects all available data in all three columns in the staff table? Select all that apply:
  • SELECT * FROM staff
  • SELECT name, email, age FROM staff
  • SELECT name, email AND age FROM staff
9. The following SQL statement returns all staff phone numbers from the staff table:  
Select phoneNumber from staff
True or false?
  • True
  • False
10. Which of the following SQL statements deletes all records of data from the staff table without deleting the table itself? Select all that apply:
  • DELETE FROM staff
  • TRUNCATE TABLE staff
  • DROP TABLE staff

Module quiz: SQL Data in React Native

1. In order to populate a React Native application upon startup with data from AsyncStorage, where is the best place to enter your code? 
  • Inside a useEffect hook with no dependencies, so the code only runs after the application has rendered for the first time.
  • In a separate file, so your code is clean and concise.
  • Inside the render part of your component.
2. The code sample below uses AsyncStorage to get an item from the disk.
const getMultiple = async () => { 
  const values = await AsyncStorage.multiGet('myKey'); 
}; 
Which elements of the above code snippet are incorrect? Select all that apply:
  • The function does not handle any errors.
  • The argument passed to multiGet is the incorrect type.
  • You can’t use multiGet to get a simple value.
3. Which API removes all AsyncStorage data for all the clients and the libraries?
  • removeItem
  • clear
  • multiRemove
4. What’s the difference between mergeItem and setItem APIs in AsyncStorage?
  • With mergeItem you need to pass the whole value again, whereas with setItem only the updated path is needed.
  • With setItem you need to pass the whole value again, whereas with mergeItem only the updated path is needed.
  • There is no difference. Both APIs achieve the same result.
5. SQLite is the best storage solution if you need to store small, independent amounts of data for your app. True or False?
  • True
  • False
6. If you need your app to process large amounts of data quickly, you should store data with AsyncStorage. True or False?
  • True
  • False
7. When using Expo SQLite, what’s the best place for opening a database connection in a React Native application?
  • Inside a useEffect hook with no dependencies.
  • In the application entry point component, but outside, right at the top of the file.
  • In a separate file, just to keep the code cleaner and more concise.
8. How do you handle errors when executing a transaction with Expo SQLite?
  • By passing an error callback function as a second argument to the db.transaction().
  • Errors are handled automatically by Expo SQLite.
  • By wrapping the transaction call with a try/catch clause. 
9. Suppose you have an application that stores a table of different customers who dine at Little Lemon restaurant. 
Each customer has a name, date of birth, and unique ID. The application has to support deleting a customer from the application the moment the customer checks out. 
What’s the most convenient SQL statement for achieving such a task?
  • delete from customers where uid = ${selectedCustomer.id}
  • delete from customers where name = ${selectedCustomer.name}
  • delete from customers where dateOfBirth = ${selectedCustomer.dateOfBirth}
10. What’s the SQL keyword that allows you to insert variables as extra parameters and not inside the SQL query itself?
  • The ! Keyword.
  • The ? Keyword.
  • The INSERT keyword.

Final graded quiz: Working with data in React Native

Random 1

1. PascalCase is the ideal naming convention for writing API endpoint names. True or False?
  • True 
  • False 
2. Which signing mechanism is used to sign an API call?  
  • TOKEN
  • HMAC
  • JWT
  • SHA
3. You have a table named Players, which contains the column playerName. What is the correct SQL statement that outputs all the player names? 
Note: When you run the correct SQL query, you should have the following output result:
+-----------------+
|  playerName    |
+-----------------+
|  + Jack             |
|  + Karl             |
|  + Mark           |
|  + Andrew       |
+-----------------+
  • SELECT playerName FROM Players;
  • SELECT Players FROM playerName;
  • CREATE TABLE Players (playerName VARCHAR(100) );
4. Complete the following sentence: In a database of students registered for a university course, the complete information about one specific student in the database is referred to as a _______ .
  • Column 
  • Table 
  • Record 
5. Authentication and authorization both provide user access and grant permissions for tasks. True or False?
  • True  
  • False  
6.Authentications The output result of the following SQL statement returns the data of all the menu items in the table of type Beverages. True or false?
SELECT * FROM menuItems WHERE type = "Beverages";
  • True 
  • False 
7. The JSON given below is a valid JSON. True or False?
  • True
  • False
8. When deleting data in AsyncStorage, which API would you use to remove data under one specific key?
  • removeItem
  • clear
  • multiRemove
9.Whet Which API is used to remove all keys from AsyncStorage data?
  • removeItem 
  • clear()
  • multiRemove
10. While making API calls within your React Native app using the fetch method, where is the best place in your code to invoke the method? 
  • Inside the render part of your component.
  • Inside a useState hook.
  • Inside a useEffect hook.

Random 2

1. Which of the following are good naming conventions for API endpoints? Select all that apply: 
  • Use PascalCase for naming the variables.
  • Use the backslash to indicate relationships.
  • User lowercase names.
  • Avoid verbs in the name.
  • Separate words using a hyphen. 
2. What are the benefits of signing an API call? Select all that apply.
  • Signed API calls can increase API security. 
  • Signed API calls are automatically validated. 
  • Signed API calls ensure data authenticity. 
  • Signed API calls are sanitized. 
  • Signed API calls can give access to a resource for a certain period of time. 
3. When referencing the following SQL statement to insert data into the Players table, what is the missing keyword?
INSERT INTO Players (playerID, playerName, age) … (1, "Jack", 25);
  • VALUES
  • DATA
  • COLUMN
4. A restaurant’s menu database includes a menu table with two columns: price and menuItemName. What is the correct data type for each column? Select all that apply.  
  • The menuItemName column data type is VARCHAR. 
  • The price column data type is INT. 
  • The menuItemName column data type is CHAR. 
  • The price column data type is DECIMAL. 
5. Which one of the following API clients and tools offer both web desktop versions?
  • Curl
  • Postman
  • Insomnia
6. A bakery’s database includes a cakes table with two columns: cakeType and price. The prices are expressed in terms fractional numbers (Example: 15.50). Which data type would you apply to the price column?
  • VARCHAR
  • INT
  • DECIMAL
7. If you run the code below, what will be displayed on the console? 
const json = '{"isCount":true, "count":100}'; 
const obj = JSON.parse(json); 
 
console.log(obj.isCount); 
  • 100
  • true
  • true, 100
8. When deleting data in AsyncStorage, which API would you use to remove data under one specific key?
  • removeItem
  • multiRemove
  • clear
9. Consider an application where the requirement is to store small amounts of data, each one independent of each other. AsyncStorage is the most suitable storage mechanism for this purpose. True or False?
  • True
  • False 
10. What’s the SQL keyword that allows you to insert new rows into the table?
  • The ? keyword 
  • The INSERT keyword 
  • The ! keyword 

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.