ReactJS Multiple-Choice Questions (MCQs)

React / ReactJS is a free and open-source front-end JavaScript library for building user interfaces based on UI components. It is maintained by Meta and a community of individual developers and companies. React can be used as a base in the development of single-page or mobile applications.

ReactJS MCQs: This section contains ReactJS Multiple-Choice Questions with Answers. These ReactJS MCQs are written for beginners as well as advanced, practice these MCQs to enhance and test the knowledge of ReactJS.

List of ReactJS MCQs

1. React is also known as _____.

  1. ReactJS
  2. js
  3. Both A. and B.
  4. None of these

Answer: C) Both A. and B.

Explanation:

React is also known as React.js and ReactJS.

Discuss this Question


2. React is a ____.

  1. Web development Framework
  2. JavaScript Library
  3. jQuery
  4. Web Server

Answer: B) JavaScript Library

Explanation:

React is a JavaScript library.

Discuss this Question


3. Which ReactJS function renders HTML to the web page?

  1. render()
  2. ReactDOM.render()
  3. renders()
  4. ReactDOM.renders()

Answer: B) ReactDOM.render()

Explanation:

The ReactDOM.render() function is used to render HTML to the web page.

Discuss this Question


4. JSX stands for _____.

  1. JSON
  2. JSON XML
  3. JavaScript XML
  4. JavaScript and AngularJS

Answer: C) JavaScript XML

Explanation:

JSX stands for JavaScript XML.

Discuss this Question


5. JSX allows us to write _____.

  1. jQuery in React
  2. Angular Code in React
  3. MySQL in React
  4. HTML in React

Answer: D) HTML in React

Explanation:

JSX allows us to write HTML in React.

Discuss this Question


6. What is the correct syntax to write expression in JSX?

  1. [ expression ]
  2. { expression }
  3. {{ expression }}
  4. _expression

Answer: B) { expression }

Explanation:

With JSX, an expression can be written using the syntax, { expression }.

Discuss this Question


7. A class component must include the _______ statement.

  1. extends React.Component
  2. extends React
  3. extends Component
  4. extends React.Component.All

Answer: A) extends React.Component

Explanation:

A class component must include the extends React.Component statement.

Discuss this Question


8. What are Props?

  1. Props are arguments passed into React components
  2. Props are functions in the ReactJS
  3. Props are used to returns multiple values from the function
  4. All of the above

Answer: A) Props are arguments passed into React components

Explanation:

Props are arguments passed into React components.

Discuss this Question


9. What does props stand for?

  1. Proper Arguments
  2. Properties
  3. Proper Return Values
  4. All of the above

Answer: B) Properties

Explanation:

The props stands for properties.

Discuss this Question


10. Which ReactJS command is used to create a new application?

  1. create-react-app
  2. new-react-app
  3. create-new-reactapp
  4. react-app

Answer: A) create-react-app

Explanation:

The create-react-app command is used to create a new React Application.

Discuss this Question


11. Which ReactJS command is used to set up everything you need to run a React Application?

  1. create-react-app
  2. new-react-app
  3. create-new-reactapp
  4. react-app

Answer: A) create-react-app

Explanation:

The create-react-app command is used to set up everything you need to run a React Application.

Discuss this Question


12. How to install create-react-app?

  1. npx create-react-app -new my-app
  2. npx create-react-app -app my-app
  3. npx new-react-app my-app
  4. npx create-react-app my-app

Answer: D) npx create-react-app my-app

Explanation:

The npx create-react-app my-app command is used to install create-react-app.

Discuss this Question


13. ES6 stands for ____.

  1. ECMAScript 6
  2. Extended-JavaScript Version 6
  3. Extensive-JavaScript 6
  4. Expanded-JavaScript 6

Answer: A) ECMAScript 6

Explanation:

ES6 stands for ECMAScript 6.

Discuss this Question


14. ECMAScript was created to standardize _____.

  1. TypeScript
  2. Java
  3. JSON
  4. JavaScript

Answer: D) JavaScript

Explanation:

ECMAScript was created to standardize JavaScript.

Discuss this Question


15. In ES6 – A class is a type of ____.

  1. Basic datatype
  2. Derived datatype
  3. Variable
  4. Function

Answer: D) Function

Explanation:

In ES6 – A class is a type of function.

Discuss this Question


16. In ES6 – Which keyword is used to initiate a class?

  1. function
  2. class
  3. ReactClass
  4. ReactClassJs

Answer: B) class

Explanation:

In ES6 – A class is a type of function, but instead of using the keyword function to initiate it, we use the keyword class.

Discuss this Question


17. In ES6 – The class properties are assigned inside a _____ method.

  1. props()
  2. properties()
  3. constructor()
  4. react-properties()

Answer: C) constructor()

Explanation:

In ES6 – The class properties are assigned inside a constructor() method.

class Laptop{
  constructor(name) {
    this.model = name;
  }
}

Discuss this Question


18. In ES6 – Which keyword is used for class inheritance?

  1. extends
  2. extend
  3. inheritance
  4. inheritances

Answer: A) extends

Explanation:

In ES6 – The extends keyword is used for class inheritance.

Discuss this Question


19. In ES6 – What is the correct syntax of class inheritance?

  1. class class1 extends class2{...}
  2. class class1 extends | class2{...}
  3. class class1 | extends class2{...}
  4. class class1 | extends | class2{...}

Answer: A) class class1 extends class2{...}

Explanation:

In ES6 – The correct syntax of class inheritance is:

class class1 extends class2{...}

Discuss this Question


20. In ES6 – Which method refers to the parent class?

  1. parent()
  2. super()
  3. top()
  4. main()

Answer: B) super()

Explanation:

In ES6 – The super() method refers to the parent class.

Discuss this Question


21. In ES6 – Why arrow functions are used?

  1. To access pointer variable
  2. To access variable of a class
  3. Both A. and B.
  4. Write shorter function syntax

Answer: D) Write shorter function syntax

Explanation:

In ES6 – The arrow functions are used to write shorter function syntax.

Discuss this Question


22. Consider the below function – which is the correct syntax of arrow function?

Msg = function() {
  return "Good Morning";
}
  1. Msg = () => {return "Good Morning";}
  2. Msg = () => "Good Morning";
  3. Both A. and B.
  4. None of the above

Answer: C) Both A. and B.

Explanation:

In ES6 – Below given both of the syntaxes are correct of arow function:

Msg = () => {
	return "Good Morning";
}
Msg = () => "Good Morning";

Discuss this Question


23. Which is the correct arrow function to add two numbers?

  1. add = (a,b) => a+b;
  2. add = (a,b) => return a+b;
  3. add = (a,b) => { return a+b;}
  4. Both A. and B.
  5. Both A. and C.

Answer: E) Both A. and C.

Explanation:

In ES6 – Below given both are the arrow functions to add two numbers:

add = (a,b) => a+b;
add = (a,b) => { return a+b;}

Discuss this Question


24. With an arrow function – this keyword represents _____.

  1. Content
  2. Header object
  3. Current object
  4. Child object

Answer: B) Header object

Explanation:

With an arrow function – this keyword represents Header object.

Discuss this Question


25. Complete the below given arrow function.

Msg = ____ "Hi, there!";
  1. ()
  2. =>
  3. ()>
  4. () =>

Answer: D) () =>

Explanation:

The correct arrow function is:

Msg = () => "Hi, there!";

Discuss this Question


26. In ES6 – Which are the keywords to define variables?

  1. var
  2. let
  3. const
  4. All of the above

Answer: D) All of the above

Explanation:

In ES6 – There are three ways of defining your variables: var, let, and const.

Discuss this Question


27. In ES6 – var has a function scope, not a block scope?

  1. True
  2. False

Answer: A) True

Explanation:

In ES6 – The statement "var has a function scope, not a block scope." is True.

Discuss this Question


28. Which is used to pass data to components from outside?

  1. Render with arguments
  2. props
  3. setState
  4. PropTypes

Answer: B) props

Explanation:

props are used to pass data to components from outside.

Discuss this Question


29. In ES6 – let is the block scoped version of ____.

  1. const
  2. function
  3. var
  4. None of the above

Answer: C) var

Explanation:

In ES6 – The let is the block scoped version of var.

Discuss this Question


30. In ES6 – let has a block scope.

  1. True
  2. False

Answer: A) True

Explanation:

In ES6 – The statement "let has a block scope." is True.

Discuss this Question


31. In ES6 – Which keyword is used to define a constant?

  1. var
  2. const
  3. let
  4. constant

Answer: B) const

Explanation:

In ES6 – The const keyword is used to define a constant.

Discuss this Question


32. Which method is used to generate lists?

  1. map()
  2. generate()
  3. new()
  4. maps()

Answer: A) map()

Explanation:

The map() method is used to generate lists in React ES6.

Discuss this Question


33. What is the default port where webpack-server runs?

  1. 443
  2. 3030
  3. 3306
  4. 8080

Answer: D) 8080

Explanation:

The default port to run webpack-server is 8080.

Discuss this Question


34. What are components in ReactJS?

  1. Components are like functions that return HTML elements.
  2. Components are the HTML elements.
  3. Components are the set of variables defined in ReactJS.
  4. None of the above

Answer: A) Components are like functions that return HTML elements.

Explanation:

In ReactJS, the components are like functions that return HTML elements.

Discuss this Question


35. How many types of the components in ReactJS?

  1. 1
  2. 2
  3. 3
  4. 4

Answer: B) 2

Explanation:

There are two types of components in ReactJS.

Discuss this Question


36. Which are the valid components in ReactJS?

  1. Variable components
  2. Function components
  3. Class components
  4. Both A. and B.
  5. Both B. and C.

Answer: E) Both B. and C.

Explanation:

There are two types of components in ReactJS, which are:

  • Function components
  • Class components

Discuss this Question


37. Which statement is required to define a class component?

  1. extends React.Components
  2. imports React.Components
  3. extends React.Component
  4. imports React.Component

Answer: C) extends React.Component

Explanation:

In ReactJS, a class component must include the extends React.Component statement.

Discuss this Question


38. Consider the below statement – Which method will be used at the place of blank space (____)?

class MainTitle extends React.Component {
  ______ {
    return <h1>Welcome at IncludeHelp!</h1>;
  }
}
  1. renderDOM()
  2. renderComponent()
  3. render()
  4. render()

Answer: C) render()

Explanation:

The correct code is:

class MainTitle extends React.Component {
  render() {
    return <h1>Welcome at IncludeHelp!</h1>;
  }
}

Discuss this Question


39. Can components be passed as props?

  1. Yes
  2. No

Answer: A) Yes

Explanation:

Yes, the components can be passed as props.

Discuss this Question


40. In ReactJS, what is State?

  1. It's a temporary storage of the elements
  2. It's a state of the execution of the ReactJS application
  3. It's an internal storage of the components
  4. All of the above

Answer: C) It's an internal storage of the components

Explanation:

In ReactJS, the State is an internal storage of the components.

Discuss this Question






Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.