SE-3003 Web Engineering Final Exam

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson
Download our mobile app to listen on the go
Get App

Questions and Answers

The API route to retrieve all doctors' information is defined as POST /api/doctors.

False (B)

The sample data for doctors includes an entry for a doctor named Dr.John Smith who specializes in Cardiology.

True (A)

The ExpressJS application handles API calls with a default method of POST.

False (B)

In the sample code provided, a specific doctor's information can be retrieved using the route GET /api/doctors/456.

<p>False (B)</p> Signup and view all the answers

The data structure for each doctor includes exactly 4 attributes: id, name, designation, and specialization.

<p>False (B)</p> Signup and view all the answers

The useEffect hook in ReactJS is used to handle user input in forms.

<p>False (B)</p> Signup and view all the answers

The React Context API is primarily used for managing state in class components.

<p>False (B)</p> Signup and view all the answers

Data is provided to components using the React Context API by defining a context object and using a Provider component to wrap the desired components.

<p>True (A)</p> Signup and view all the answers

Redux is primarily used to enable server-side rendering of React components.

<p>False (B)</p> Signup and view all the answers

The 'dispatch' function in Redux updates the store by applying the specified action.

<p>True (A)</p> Signup and view all the answers

BrowserRouter is the primary routing component used in React Routing v6.

<p>True (A)</p> Signup and view all the answers

The useHistory hook is used to navigate programmatically in React Routing v6.

<p>False (B)</p> Signup and view all the answers

It is a standard practice to store JWT Secrets in a JSON file.

<p>False (B)</p> Signup and view all the answers

The specialization of the doctor in the provided code is Pediatrics.

<p>False (B)</p> Signup and view all the answers

The output on the console when the component is rendered for the first time includes 'Component rendered successfully'.

<p>False (B)</p> Signup and view all the answers

The DELETE endpoint in the API returns a message stating 'Doctor deleted successfully.' when a doctor is deleted.

<p>True (A)</p> Signup and view all the answers

The doctor is found in the system when a valid ID is provided to the PUT API endpoint.

<p>True (A)</p> Signup and view all the answers

The output displayed on the web page when the button is clicked for the first time is 'I'm Not Ready!'.

<p>False (B)</p> Signup and view all the answers

The application uses a hook called useEffect which runs only when the component mounts.

<p>False (B)</p> Signup and view all the answers

If a doctor with the given ID is not found in the database, the DELETE request will return a 200 status code.

<p>False (B)</p> Signup and view all the answers

In the given sample code, clicking the button calls the setReady function with false.

<p>False (B)</p> Signup and view all the answers

The useEffect hook is called every time the component re-renders.

<p>False (B)</p> Signup and view all the answers

SetTimeout is used to delay the execution of fetchMessages by one second.

<p>True (A)</p> Signup and view all the answers

The ChildC component directly receives props without any parent components passing them down.

<p>False (B)</p> Signup and view all the answers

Context API is useful for passing data without prop drilling in deeply nested components.

<p>True (A)</p> Signup and view all the answers

The UserContext is created using the createContext method from React.

<p>True (A)</p> Signup and view all the answers

SetMessages function updates the state directly without any arguments.

<p>False (B)</p> Signup and view all the answers

If user state in the Parent component is an empty array, ChildC will print 'Username is: ' with no value.

<p>True (A)</p> Signup and view all the answers

React Router is not applicable to a multi-level navigation structure in a React application.

<p>False (B)</p> Signup and view all the answers

The output of the given function will display 'Item 1' and 'Item 2' on the screen.

<p>False (B)</p> Signup and view all the answers

The code provided for PostList will show 'No posts available.' if there are no posts.

<p>True (A)</p> Signup and view all the answers

In the ChatWindow component, messages are fetched from the API each time the component is rendered.

<p>False (B)</p> Signup and view all the answers

The PostList component correctly maps over posts using 'posts.title' and 'posts.body'.

<p>False (B)</p> Signup and view all the answers

The return statement in the App function does not properly return any JSX because of missing parentheses.

<p>True (A)</p> Signup and view all the answers

The fetchMessages function will log an error message to the console if the API call fails.

<p>True (A)</p> Signup and view all the answers

The mapping function used in the ChatWindow component correctly displays 'message.text'.

<p>False (B)</p> Signup and view all the answers

The given code guarantees that messages will be displayed as a list in the ChatWindow component.

<p>False (B)</p> Signup and view all the answers

The Admin Dashboard route is identified by the path '/admin/home'.

<p>False (B)</p> Signup and view all the answers

The Redux slice named 'posts' in the given code has an initial state containing an empty array for posts.

<p>True (A)</p> Signup and view all the answers

In the ProfileComponent, the useEffect dependency array includes the 'posts' variable.

<p>True (A)</p> Signup and view all the answers

The fetch_posts action immediately updates the state with the fetched posts data.

<p>False (B)</p> Signup and view all the answers

The configureStore function is imported from '@redux/react'.

<p>False (B)</p> Signup and view all the answers

The path '/products/:id' allows access to specific product details based on the product's id.

<p>True (A)</p> Signup and view all the answers

The Admin Categories route is the same as the path '/categories/admin'.

<p>False (B)</p> Signup and view all the answers

The ProfileComponent will only render when the component's local state is updated.

<p>False (B)</p> Signup and view all the answers

Flashcards

useEffect

A built-in React hook used to perform side effects, such as fetching data, setting up subscriptions, or managing timers. It runs after every render and allows interaction with the outside world.

useState

A built-in React hook that helps you manage the state of your component, allowing you to store and update data that changes over time.

React Context API

A feature in React that provides a centralized way to manage and share data across different components in your application, reducing the need for prop drilling.

Redux

A robust library for managing state in React applications. It offers a centralized store, actions, and reducers for predictable and efficient state updates.

Signup and view all the flashcards

dispatch function in Redux

The function in Redux that is used to trigger state changes by dispatching actions to the store. These actions are then processed by reducers, which update the state.

Signup and view all the flashcards

BrowserRouter in React Router v6

The main routing component in React Router v6, providing the foundation for creating a navigation system in your React application.

Signup and view all the flashcards

useNavigate in React Router v6

A React hook used to programmatically navigate to different routes within your application without relying on the browser's built-in history.

Signup and view all the flashcards

Route with parameters in React Router v6

Allows you to define routes that accept dynamic parameters, enabling flexibility and content customization based on those parameters.

Signup and view all the flashcards

JWT

A method to represent and exchange secure information between parties. It is used to securely transmit information over HTTP without exposing sensitive data.

Signup and view all the flashcards

dotenv

A library that allows reading environment variables from a '.env' file, separating sensitive data from code.

Signup and view all the flashcards

ExpressJS

A web application framework for Node.js. It simplifies building APIs and web applications.

Signup and view all the flashcards

GET Request

A request sent to a server to retrieve data from a specific resource.

Signup and view all the flashcards

API Route

A web service that handles CRUD operations for a specific resource, such as a doctor's information.

Signup and view all the flashcards

useNavigate

A component in React Router v6 that allows navigating to different routes in an application without relying on the browser's history.

Signup and view all the flashcards

Route with parameters

A feature of React Router v6 that lets you define routes with dynamic parameters, making routes flexible and content adaptable.

Signup and view all the flashcards

BrowserRouter

A route in React Router v6 that acts as the main routing component, laying the groundwork for navigation within a React application.

Signup and view all the flashcards

Initial state of post reducer

The initial state of the Redux store for posts, initialized with an empty array of posts.

Signup and view all the flashcards

fetch_posts reducer

A Redux reducer function that fetches posts from a URL and updates the state with the fetched data.

Signup and view all the flashcards

fetch_posts action

An action creator that triggers the fetch_posts reducer, initiating the process of fetching and storing posts from a URL.

Signup and view all the flashcards

Redux store

A Redux store that holds the state of the application, specifically the posts state managed by the postReducer.

Signup and view all the flashcards

ProfileComponent

A React component that displays the posts retrieved from the Redux store, showcasing the state in the application.

Signup and view all the flashcards

JavaScript map() method

The map() method in JavaScript iterates over an array and applies a function to each element, creating a new array with the results.

Signup and view all the flashcards

How does the map() method work?

The map() method in JavaScript is used to create a new array by applying a function to each element of an existing array. This function can modify the element or return a new value based on the existing element.

Signup and view all the flashcards

What does items.map(item => item.text) do?

For each item in the items array, the map() method calls the provided function, which extracts the text property of each item. The result is a new array containing the text values.

Signup and view all the flashcards

Ternary Operator

The ternary operator is a shorthand way to write conditional expressions in JavaScript. It allows you to assign a value to a variable based on a condition, creating a concise way to handle if-else logic.

Signup and view all the flashcards

What does return do in React?

The return keyword in React components specifies what the component should render to the screen. It can return a single JSX element, an array of JSX elements, or a fragment.

Signup and view all the flashcards

What is the fetch API?

The fetch API is a built-in way to make network requests in JavaScript. It allows you to retrieve data from servers or send data to servers, enabling communication with external resources.

Signup and view all the flashcards

What are async/await?

The async/await keywords in JavaScript are used to handle asynchronous operations, such as network requests. They make it easier to write code that waits for a response before proceeding.

Signup and view all the flashcards

What is useEffect?

The useEffect hook in React enables you to perform side effects in your components. These side effects can include fetching data from an API, setting up event listeners, or managing timers.

Signup and view all the flashcards

What are side effects in React and why are they important?

The useEffect hook in React allows you to perform side effects within a component. It is typically used for tasks like fetching data, setting up subscriptions, or managing timers. It automatically runs after every render.

Signup and view all the flashcards

How can you make a useEffect run only once when a component mounts?

The useEffect hook, when paired with the dependency array [], ensures that the function inside it runs only once when the component initially renders. This is often used to fetch data only once on mount.

Signup and view all the flashcards

What is the purpose of the fetchMessages function in the provided code snippet?

Data is fetched from the server using the fetchMessages function. This function is called inside the useEffect hook to retrieve data.

Signup and view all the flashcards

How is the code snippet modified to fetch messages after a one-second delay?

This code snippet utilizes the setTimeout function to delay the execution of fetchMessages for one second after the component renders. This introduces a deliberate delay in data fetching.

Signup and view all the flashcards

Describe the component hierarchy in the provided React code snippet.

The Parent component renders the ChildA, ChildB, and ChildC components in a nested structure. Each child component receives props passed down from its parent.

Signup and view all the flashcards

What is prop drilling in React development, and what are the drawbacks?

Prop drilling refers to passing data through multiple levels of nested components using props. This can become tedious and unmanageable for complex component hierarchies.

Signup and view all the flashcards

What is the purpose of the React.createContext function in the code, and what is the significance of the UserContext?

The React.createContext function creates a context object. The UserContext context is initialized here, providing a central location to share data across components.

Signup and view all the flashcards

How is the useContext hook used within the ChildC component to retrieve data from the UserContext without prop drilling?

The useContext hook is used within the ChildC component to access the value stored in the UserContext. This eliminates the need to pass the username prop through the component hierarchy.

Signup and view all the flashcards

What is the useEffect hook?

The useEffect hook allows you to perform side effects in your functional React components, such as fetching data, setting up subscriptions, and manipulating the DOM. It takes a callback function that will be executed after every render, and optionally an array of dependencies. When the dependencies change, the effect function will be re-run.

Signup and view all the flashcards

What is the purpose of the useEffect hook in this code snippet?

In this code, the useEffect hook is used to log a message to the console after the component has been successfully rendered. The dependency array [ready] indicates that the effect should re-run whenever the ready state variable changes.

Signup and view all the flashcards

What is the useState hook?

The useState hook is a built-in React function that allows you to manage state within a functional component. It takes an initial value as an argument and returns an array containing two elements: the current state value and a function to update the state.

Signup and view all the flashcards

What is the purpose of the useState hook in this code?

In this code, the useState hook is used to track whether the button is ready to be clicked.

Signup and view all the flashcards

How is the 'ready' state updated?

The initial state of the ready variable is set to false. When the button is clicked, the setReady function is called with true, changing the state to true and triggering the useEffect hook to re-run.

Signup and view all the flashcards

What is the output on the console when the component is rendered first time?

The statement console.log('State is Ready!') and console.log('Returning JSX') are executed when the component is first rendered, before the useEffect hook is triggered. This means the output on the console will be "State is Ready!" followed by "Returning JSX" .

Signup and view all the flashcards

What is the output on the console when the component is rendered successfully?

The useEffect hook executes after the component is rendered, so it will log "Component rendered successfully" after the initial render.

Signup and view all the flashcards

What is the output on the console and web page when the button is clicked for the first time?

When the button is first clicked, the state is updated to true by calling setReady(true). The useEffect hook will re-run because its dependency array is [ready], resulting in a new console log of "Component rendered successfully", but the text on the web page will update to "Ready!".

Signup and view all the flashcards

Study Notes

SE-3003: Web Engineering Final Exam

  • Exam scheduled for Wednesday, May 24, 2023
  • Exam duration: 3 hours
  • Total marks: 100

Instructions

  • Attempt all questions
  • Plan answers carefully
  • Write optimized, concise code
  • Ensure code works optimally
  • Use permanent ink pens
  • Verify the number of pages (18 including title page)
  • Question paper contains 3 questions

Question 1 (20 Marks)

  • Multiple choice questions (1 mark each)
  • Correct answers must be written in uppercase letters
  • Overwriting/cutting answers will not be marked

Question 2 (20 Marks)

  • 5 sub-questions
  • Each sub-question requires API calls for CRUD operations in ExpressJS
  • Data source to be used must be specified
  • Implement routes to retrieve all doctors, get specific doctor, add a new doctor, update existing doctor and delete a doctor
  • Examples of expected input and output are provided in the question paper.

Question 3 (60 Marks)

  • 3 sub-questions based on code snippets
  • Question 3(a) asks for console output upon component's first render
  • Question 3(b) asks for console output on button click
  • Question 3(c) asks what will be displayed on the web page upon button click
  • Question 3(2) asks for the output of a given code snippet
  • Question 3(3) requires completion of a missing code snippet
  • Question 3(4) focuses on retrieving messages from an API
  • Question 3(5) discusses updating code to fetch messages in one second
  • Question 3(6a) asks for completing a React code for Parent component
  • Question 3(6b) asks for issues with the approach and avoiding them
  • Question 3(6c) asks to implement React's prescribed approach to pass props

Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

Quiz Team

Related Documents

More Like This

Lec 5 - ExpressJS
40 questions

Lec 5 - ExpressJS

ImaginativeHedgehog avatar
ImaginativeHedgehog
Express
15 questions
Express Routing and Performance Quiz
17 questions
Preguntas sobre Node.js y Express
16 questions
Use Quizgecko on...
Browser
Browser