About React JS

Following are some of the multiple choice questions on the React JS with answers that will help the students in developing their knowledge.

React JS MCQ

1. One can define default values for properties, props, using which of the following method?

  • getDefaultProps
  • getPropsValue
  • getInitialState

2. In which directory React Components are saved?

  • Inside js/components/
  • Inside vendor/components/
  • Inside external/components/
  • Inside vendor/

3. How many elements does a react component return?

  • 2 Elements
  • 1 Element
  • Multiple Elements
  • None of These

4. What is state in React?

  • A persistant storage.
  • An internal data store (object) of a component.

5. What is Babel?

  • A transpiler.
  • An interpreter
  • A Compiler
  • Both Compiler and Transpilar

6. What does the "webpack" command do?

  • Transpiles all the Javascript down into one file
  • Runs react local development server.
  • A module bundler

7. What port is the default where the webpack-dev-server will run?

  • 3000
  • 8080
  • 4000
  • 3306

8. What is ReactJS?

  • Server side Framework
  • User-interface framework
  • A Library for building interaction interfaces
  • None of the above

9. What are the two ways that data gets handled in React?

  • state & props
  • services & components

10. In React what is used to pass data to a component from outside?

  • setState
  • render with arguments
  • props
  • PropTypes

11. Everything in React is a _____________

  • Module
  • Component
  • Package
  • Class

12. Life cycle methods of a components fall under following categories?

  • Mounting, Unmounting
  • Mounting, Updating
  • Mounting, Updating, Unmounting

13. Which of the following API is a MUST for every ReactJS component?

  • getInitialState
  • render
  • renderComponent
  • None of the above

14. Which method is not part of ReactDOM?

  • ReactDOM.destroy()
  • ReactDOM.hydrate()
  • ReactDOM.createPortal()
  • ReactDOM.findDOMNode()

15. At the highest level, React components have lifecycle events that fall into

  • Initialization
  • State/Property Updates
  • Destruction
  • All of these

16. What happens when the following render() method executes?<br /><br /> render(){<br /> let langs = ["Ruby","ES6","Scala"]<br /> return (<div><br /> {langs.map(it => <p>{it}</p>)}<br /> </div>)<br /> }<br />

  • Displays the list of languages in the array
  • Error. Cannot use direct JavaScript code in JSX
  • Displays nothing
  • Error. Should be replaced with a for..loop for correct output

17. How do you write an inline style specifying the font-size:12px and color:red; in JSX

  • style={{font-size:12,color:'red'}}
  • style={{fontSize:'12px',color:'red'}}
  • style={fontSize:'12px',color:'red'}
  • style={{font-size:12px,color:'red'}}

18. Which of the following is correct syntax for a button click event handler, foo?

  • <button onclick=this.foo()>
  • <button onclick=this.foo>
  • <button onClick={this.foo()}>
  • <button onClick={foo}>

19. What function allows you to render React content in an HTML page?

  • React.mount()
  • ReactDOM.start()
  • ReactDOM.render()
  • React.render()

20. Which of the following below act as the input of a class-based component?

  • class and factory
  • render and mount
  • props

21. Who Develop React.js?

  • Apple
  • Facebook
  • Twitter
  • Google

22. . .............. helps react for keeping their data unidirectional.

  • JSX
  • Flux
  • Dom
  • Props

23. What is a controlled input element?

  • An input element with the controlled flag
  • An input element whose value is being controlled by a component’s state
  • An input element that can only accept a list of characters
  • An input element that is controlled by the value of another input element

24. What is the declarative way to render a dynamic list of components based on values in an array

  • Using the reduce array method
  • With a for/while loop
  • Using the <Each /> component
  • Using the Array.map() method

25. When it is recommended to pass this.setState as a function instead of an object?

  • When the new state should completely replace the old state
  • When the new state depends on the old state
  • When the new state does not depend on the old state
  • None of the above

26. What will happen 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

27. What is a good use case for using a function while rendering a dynamic list of items

  • If we need to compute a value based on properties of items in the loop.
  • None. Functions should not be used while rendering a dynamic list.
  • To make the code shorter
  • None of the above

28. What is the second argument for setState useful for?

  • To invoke code after the setState operation is done
  • To replace the state completely instead of the default merge action
  • To access the previous state before the setState operation
  • None of the above

29. React.js Covers only the view layer of the app.

  • Yes
  • No

30. What is used in ReactJs to increase performance

  • Both B and c
  • Original DOM
  • Virtual DOM
  • None of the above

31. ReactJs cover

  • User Interface layer in an application
  • Data layer in an application
  • Both A and B
  • None of the above

32. Who is the father of React.js?

  • Jordan mike
  • Jordan Walke
  • Nile
  • Nike John

33. React.js in MVC is

  • Model
  • Middleware
  • View
  • None of the above

34. Everything in react is

  • Component
  • Model
  • Method
  • Package

35. React component can return how many html tags

  • one
  • multiple
  • two
  • three

36. Must API for every ReactJs component

  • SetinitialComponent
  • renderComponent
  • render
  • All of the above

37. Babel is

  • Compiler
  • Transpilar
  • None of the above
  • Both A and B

Enjoyed the Quiz. Share this with friends


Add Your Review

Your email address will not be published.

Subscribe to Newsletter!

Subscribe to get latest updates and information.