React MCQ

  • ReactJS is a JavaScript library originally developed by Facebook.
  • it helps in building highly engaging single-page web apps.
  • react JS helps in breaking down the complex into simpler components.
  • NPX: It is an npm package that is expected to be done only once in a project.
  • Folder structure:
    • Readme.md:  it is used to generate an HTML summary.
    • .gitignore:  files that you do not want to push in GitHub.
    • public/index.html: HTML file of our react app. This is the page that will be loaded on starting the application.
    • src/index.js: JS File corresponding to index.html file.
    • src/app.js: The main component of any react app.  it acts as a container for all other components.
    • src/ app.css :  Hills in injection styling in react app
  • JSX:  it allows to write HTML in JavaScript and place them in DOM  without any child() or createElement() method.
  • Components in react:
    • they are nothing but reusable JavaScript function
    • even if the component does not depend on each other,  they merge inside a parent component to produce the final UI.
  • Benefits:
    • allows reusability of code
    • makes it easier to find a tailor
       

React MCQs

1. 

When setState()  is called inside render() method, which of the following events takes place?

duplicate key error

repetitive output happiness on the screen

nothing happens

stackoverflow error

2. 

State whether true or false: React.js covers only the view layer of the app.

True

False

3. 

The function which is called to render HTML to a web page in react?

ReactDOM_render()

render()

render_DOM()

DOM_HTML()

4. 

Total ways of defining variables in ES6 is?

1

2

3

4

5. 

Using which of the following command can prevent default behaviour at in react?

preventDefault()

avoidDefault()

revokeDefault()

None of the above

6. 

What are arbitrary inputs of components in react also known as?

Elements

Props

Keys

Ref

7. 

What happens if you render an input element with disabled = {false}?

it will be rendered as enabled

it will be rendered as disabled

it will not be rendered at all

None of the above

8. 

What is Babel?

JavaScript compiler

JavaScript interpreter

JavaScript transpiler

None of the above

9. 

What is ReactJS mainly used for building?

Database

Connectivity

User interface

Design platform

10. 

What is ReactJS?

Server-side framework

user interface framework

both a and b

none of the above

11. 

What is the functionality of a “webpack” command?

Runs react local development server

transfer files all the JavaScript down into one file

a module blunder

none of the above

12. 

What is used to handle code-splitting?

React.lazy

React.memo

React.fallback

React.split

13. 

When is useReducer used over useState in React component?

When we want to replace redux

when we want to break our production app

when we want to improve performance

none of the above

14. 

State whether true or false: React merges the objects you provide into the current state using setState().

True

False

15. 

Which company developed ReactJS?

Apple

Facebook

Google

Twitter

16. 

Which of the following are two ways to handle data in react?

services and components

State and props

state and services

state and component

17. 

Which of the following function is used to change the state of react component?

this.setState()

this.state()

this.setChangeState()

None of the above

18. 

Which of the following is used in React.js to increase performance?

Virtual DOM

Original DOM

Both A and B

None of the above

19. 

Which of the following is used to access a function fetch()  from h1 element in JSX?

<h1>${fetch()}</h1>

<h1>{fetch}</h1>

<h1>${fetch}</h1>

<h1>{fetch()}</h1>

20. 

Which of the following method is used to access the state of a component from inside of a member function?

this.prototype.stateValue

this,getState()

this.values

this.state

21. 

Which of the following port is the default where webpack-dev-server runs?

3000

3306

3030

8080

22. 

Which of the following terms commonly described react applications?

Imperative

Integrated

Declarative

closed

23. 

Who created React.js?

Jordan Mike

Jordan Walke

Tim Lee

Jordan Lee

24. 

Why is ref used?

to bind the function

to call a function

to directly access the DOM node

to refer to another JS file

25. 

Why is useLayoutEffect used?

To complete the update

to optimize for all devices

To change the layout of the screen

when you need the browser to paint before the effectors

26. 

How many elements can a valid react component return?

1

2

3

4

27. 

Among the corner which is a must-have for every ReactJS component?

renderComponent

SetinitialComponent

Render

All of the above

28. 

Among The following options, choose the one which helps react for keeping their data uni-directional?

DOM

Flux

JSX

Props

29. 

Among the following which acts as the input of class-based component?

Factory

Render

Class

props

30. 

Among the following which is used to create a class inheritance?

Inherits

Extends

Create

this 

31. 

Choose the component which should be overridden to stop the component from updating?

componentDidUpdate

componentDidMount

willComponentUpdate

shouldComponentUpdate

32. 

Choose the correct data flow sequence of flux concept.

Action -> Dispatcher -> Store -> View

Action -> Dispatcher -> View -> Store

Action -> Store -> View -> Dispatcher

Dispatcher -> Action -> Store -> View

33. 

Choose the correct statement in the context of uncontrolled components in ReactJS?

source of truth can be anything

source of truth is a component state

source of truth is DOM

none of the above

34. 

Choose the functionality of setState?

Access the previous state before the setState operation.

invoke code after the setState  operation is done

replace this date completely instead of the default merge actionnone of the above

none of the above

35. 

Choose the library which is most often associated with react?

Sinon

Chai

Jest

Mocha

36. 

Choose the method which is not a part of ReactDOM?

ReactDOM.createPortal()

ReactDOM.hydrate()

ReactDOM.destroy()

ReactDOM.findDOMNode()

37. 

Choose the method with refers to the parent class in ReactJS?

this()

super()

iniherits()

self()

38. 

ES6 stands for _________

ECMA 6

ECMAJavaScript 6

ECMAScript 6

EJavaScript 6

39. 

A state in React.js is also known as?

The internal storage of the component

External storage of the component

Permanent storage

All of the above

40. 

Identify the command used to create a react app.

npm install create-react-app

npm install -g create-react-app

install -g create-react-app

None of the above

41. 

Identify the one which is used to pass data to components from outside

Render with arguments

setState

PropTypes

props

42. 

Identify the smallest building block of React.JS.

Props

Elements

Components

None of the above

43. 

In MVC, what does React.js act as?

Model

Controller

View

Middleware

44. 

In react, the key should be?

Unique among his siblings only

unique in the DOM

Does not requires to be unique

all of the above

45. 

In which directory is react component saved?

vendor/js/components/

components/js

js/components

vendor/components

46. 

In which language is React.js written?

Python

JavaScript

Java

PHP

47. 

JSX stands for __________

Javascript XML

JSON XML

JSON

Javascript and AngularJS

48. 

React is a ___________

JavaScript framework

JavaScript library

both  a and b

none of the above

49. 

State whether true or false:  Props are methods into other components?

True

False

50. 

State whether true or false: React creates virtual DOM in memory.

True

False

Get Placed at Top Product Companies with Scaler Hide