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 _____.
- ReactJS
- js
- Both A. and B.
- None of these
Answer: C) Both A. and B.
Explanation:
React is also known as React.js and ReactJS.
2. React is a ____.
- Web development Framework
- JavaScript Library
- jQuery
- Web Server
Answer: B) JavaScript Library
Explanation:
React is a JavaScript library.
3. Which ReactJS function renders HTML to the web page?
- render()
- ReactDOM.render()
- renders()
- ReactDOM.renders()
Answer: B) ReactDOM.render()
Explanation:
The ReactDOM.render() function is used to render HTML to the web page.
4. JSX stands for _____.
- JSON
- JSON XML
- JavaScript XML
- JavaScript and AngularJS
Answer: C) JavaScript XML
Explanation:
JSX stands for JavaScript XML.
5. JSX allows us to write _____.
- jQuery in React
- Angular Code in React
- MySQL in React
- HTML in React
Answer: D) HTML in React
Explanation:
JSX allows us to write HTML in React.
6. What is the correct syntax to write expression in JSX?
- [ expression ]
- { expression }
- {{ expression }}
- _expression
Answer: B) { expression }
Explanation:
With JSX, an expression can be written using the syntax, { expression }.
7. A class component must include the _______ statement.
- extends React.Component
- extends React
- extends Component
- extends React.Component.All
Answer: A) extends React.Component
Explanation:
A class component must include the extends React.Component statement.
8. What are Props?
- Props are arguments passed into React components
- Props are functions in the ReactJS
- Props are used to returns multiple values from the function
- All of the above
Answer: A) Props are arguments passed into React components
Explanation:
Props are arguments passed into React components.
9. What does props stand for?
- Proper Arguments
- Properties
- Proper Return Values
- All of the above
Answer: B) Properties
Explanation:
The props stands for properties.
10. Which ReactJS command is used to create a new application?
- create-react-app
- new-react-app
- create-new-reactapp
- react-app
Answer: A) create-react-app
Explanation:
The create-react-app command is used to create a new React Application.
11. Which ReactJS command is used to set up everything you need to run a React Application?
- create-react-app
- new-react-app
- create-new-reactapp
- 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.
12. How to install create-react-app?
- npx create-react-app -new my-app
- npx create-react-app -app my-app
- npx new-react-app my-app
- 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.
13. ES6 stands for ____.
- ECMAScript 6
- Extended-JavaScript Version 6
- Extensive-JavaScript 6
- Expanded-JavaScript 6
Answer: A) ECMAScript 6
Explanation:
ES6 stands for ECMAScript 6.
14. ECMAScript was created to standardize _____.
- TypeScript
- Java
- JSON
- JavaScript
Answer: D) JavaScript
Explanation:
ECMAScript was created to standardize JavaScript.
15. In ES6 – A class is a type of ____.
- Basic datatype
- Derived datatype
- Variable
- Function
Answer: D) Function
Explanation:
In ES6 – A class is a type of function.
16. In ES6 – Which keyword is used to initiate a class?
- function
- class
- ReactClass
- 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.
17. In ES6 – The class properties are assigned inside a _____ method.
- props()
- properties()
- constructor()
- react-properties()
Answer: C) constructor()
Explanation:
In ES6 – The class properties are assigned inside a constructor() method.
class Laptop{
constructor(name) {
this.model = name;
}
}
18. In ES6 – Which keyword is used for class inheritance?
- extends
- extend
- inheritance
- inheritances
Answer: A) extends
Explanation:
In ES6 – The extends keyword is used for class inheritance.
19. In ES6 – What is the correct syntax of class inheritance?
- class class1 extends class2{…}
- class class1 extends | class2{…}
- class class1 | extends class2{…}
- class class1 | extends | class2{…}
Answer: A) class class1 extends class2{…}
Explanation:
In ES6 – The correct syntax of class inheritance is:
class class1 extends class2{…}
20. In ES6 – Which method refers to the parent class?
- parent()
- super()
- top()
- main()
Answer: B) super()
Explanation:
In ES6 – The super() method refers to the parent class.
21. In ES6 – Why arrow functions are used?
- To access pointer variable
- To access variable of a class
- Both A. and B.
- Write shorter function syntax
Answer: D) Write shorter function syntax
Explanation:
In ES6 – The arrow functions are used to write shorter function syntax.
22. Consider the below function – which is the correct syntax of arrow function?
Msg = function() {
return “Good Morning”;
}
- Msg = () => {return “Good Morning”;}
- Msg = () => “Good Morning”;
- Both A. and B.
- 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”;
23. Which is the correct arrow function to add two numbers?
- add = (a,b) => a+b;
- add = (a,b) => return a+b;
- add = (a,b) => { return a+b;}
- Both A. and B.
- 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;}
24. With an arrow function – this keyword represents _____.
- Content
- Header object
- Current object
- Child object
Answer: B) Header object
Explanation:
With an arrow function – this keyword represents Header object.
25. Complete the below given arrow function.
Msg = ____ “Hi, there!”;
- ()
- =>
- ()>
- () =>
Answer: D) () =>
Explanation:
The correct arrow function is:
Msg = () => “Hi, there!”;
26. In ES6 – Which are the keywords to define variables?
- var
- let
- const
- 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.
27. In ES6 – var has a function scope, not a block scope?
- True
- False
Answer: A) True
Explanation:
In ES6 – The statement “var has a function scope, not a block scope.” is True.
28. Which is used to pass data to components from outside?
- Render with arguments
- props
- setState
- PropTypes
Answer: B) props
Explanation:
props are used to pass data to components from outside.
29. In ES6 – let is the block scoped version of ____.
- const
- function
- var
- None of the above
Answer: C) var
Explanation:
In ES6 – The let is the block scoped version of var.
30. In ES6 – let has a block scope.
- True
- False
Answer: A) True
Explanation:
In ES6 – The statement “let has a block scope.” is True.
31. In ES6 – Which keyword is used to define a constant?
- var
- const
- let
- constant
Answer: B) const
Explanation:
In ES6 – The const keyword is used to define a constant.
32. Which method is used to generate lists?
- map()
- generate()
- new()
- maps()
Answer: A) map()
Explanation:
The map() method is used to generate lists in React ES6.
33. What is the default port where webpack-server runs?
- 443
- 3030
- 3306
- 8080
Answer: D) 8080
Explanation:
The default port to run webpack-server is 8080.
34. What are components in ReactJS?
- Components are like functions that return HTML elements.
- Components are the HTML elements.
- Components are the set of variables defined in ReactJS.
- 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.
35. How many types of the components in ReactJS?
- 1
- 2
- 3
- 4
Answer: B) 2
Explanation:
There are two types of components in ReactJS.
36. Which are the valid components in ReactJS?
- Variable components
- Function components
- Class components
- Both A. and B.
- 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
37. Which statement is required to define a class component?
- extends React.Components
- imports React.Components
- extends React.Component
- imports React.Component
Answer: C) extends React.Component
Explanation:
In ReactJS, a class component must include the extends React.Component statement.
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>;
}
}
- renderDOM()
- renderComponent()
- render()
- render()
Answer: C) render()
Explanation:
The correct code is:
class MainTitle extends React.Component {
render() {
return <h1>Welcome at IncludeHelp!</h1>;
}
}
39. Can components be passed as props?
- Yes
- No
Answer: A) Yes
Explanation:
Yes, the components can be passed as props.
40. In ReactJS, what is State?
- It’s a temporary storage of the elements
- It’s a state of the execution of the ReactJS application
- It’s an internal storage of the components
- 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.
[…] ReactJS Multiple-Choice Questions […]
[…] ReactJS Multiple-Choice Questions […]
[…] ReactJS Multiple-Choice Questions […]
[…] ReactJS Multiple-Choice Questions […]
[…] ReactJS Multiple-Choice Questions […]
[…] ReactJS Multiple-Choice Questions […]
[…] ReactJS Multiple-Choice Questions […]
[…] ReactJS Multiple-Choice Questions […]
[…] ReactJS Multiple-Choice Questions […]
[…] ReactJS Multiple-Choice Questions […]
[…] ReactJS Multiple-Choice Questions […]
[…] ReactJS Multiple-Choice Questions […]
[…] ReactJS Multiple-Choice Questions […]
[…] ReactJS Multiple-Choice Questions […]
[…] ReactJS Multiple-Choice Questions […]
[…] ReactJS Multiple-Choice Questions […]
[…] ReactJS Multiple-Choice Questions […]
[…] ReactJS Multiple-Choice Questions […]
[…] ReactJS Multiple-Choice Questions […]
[…] ReactJS Multiple-Choice Questions […]
[…] ReactJS Multiple-Choice Questions […]
[…] ReactJS Multiple-Choice Questions […]
[…] ReactJS Multiple-Choice Questions […]
[…] ReactJS Multiple-Choice Questions […]
[…] ReactJS Multiple-Choice Questions […]
[…] ReactJS Multiple-Choice Questions […]
[…] ReactJS Multiple-Choice Questions […]
[…] ReactJS Multiple-Choice Questions […]
[…] ReactJS Multiple-Choice Questions […]
[…] ReactJS Multiple-Choice Questions […]
[…] ReactJS Multiple-Choice Questions […]
[…] ReactJS Multiple-Choice Questions […]
[…] ReactJS Multiple-Choice Questions […]
[…] ReactJS Multiple-Choice Questions […]
[…] ReactJS Multiple-Choice Questions […]
[…] ReactJS Multiple-Choice Questions […]
[…] ReactJS Multiple-Choice Questions […]
[…] ReactJS Multiple-Choice Questions […]
[…] ReactJS Multiple-Choice Questions […]
[…] ReactJS Multiple-Choice Questions […]
[…] ReactJS Multiple-Choice Questions […]
[…] ReactJS Multiple-Choice Questions […]
[…] ReactJS Multiple-Choice Questions […]
[…] ReactJS Multiple-Choice Questions […]
[…] ReactJS Multiple-Choice Questions […]