Top 35+ Most Asked React.js MCQ1) Which of the following is the correct name of React.js?
Answer: D is the correct option. React.js is a free, open-source front-end JavaScript library used for building user interfaces or UI components. It is also known as React or ReactJS. 2) Which of the following are the advantages of React.js?
Answer: D is the correct option as all of the above statements are the advantages of React.js. 3) Which of the following is not a disadvantage of React.js?
Answer: C is the correct answer. "The JSX in React.js makes code easy to read and write" is an advantage of React.js. 4) Which of the following command is used to install create-react-app?
Answer: A is the correct answer. The "npm install -g create-react-app" command is used to install the create-react-app. 5) What of the following is used in React.js to increase performance?
Answer: B is the correct answer. Virtual DOM is used in React.js to increase performance. 6) A class is a type of function, but instead of using the keyword function to initiate it, which keyword do we use?
Answer: B is the correct answer. A class is a type of function, but instead of using the keyword function to initiate it, we use the keyword class. 7) Which of the following acts as the input of a class-based component?
Answer: D "props" is the correct answer. 8) Which of the following keyword is used to create a class inheritance?
Answer: C is the correct answer. The "Extends" keyword is used to create a class inheritance. 9) What would be the output of the following example?
Answer: D is the correct option. The two adjacent elements in JSX should be wrapped in an element so, this program will result an error. 10) What is the default port where webpack-server runs?
Answer: B is the correct answer. The default port for webpack-server is 8080. 11) How many numbers of elements a valid react component can return?
Answer: A is the correct answer. In react component, we can return only one element. 12) What is the declarative way to render a dynamic list of components based on values in an array?
Answer: C is the correct option. The Array.map() method is used to render a dynamic list of components based on values in an array. 13) How many ways of defining your variables in ES6?
Answer: B is the correct option. In ES6, there are three ways of defining your variables: var, let, and const. 14) What is a state in React?
Answer: B is the correct answer. 15) What are the two ways to handle data in React?
Answer: A "State & Props" is the correct answer. 16) In which of the following directory React.js components are saved?
Answer: A is the correct option. The React.js components are saved in "Inside the js/components/." 17) Which of the following is a must API for every React.js component?
Answer: B is the correct option. The renderComponent is a must API for every React.js component. 18) Which of the following option is correct in the case of the Babel?
Answer: D is the correct option as both of the above statements are correct. 19) Does React.js create a VIRTUAL DOM in the memory?
Answer: A is the correct option as React.js creates a VIRTUAL DOM in the memory. 20) What is the use of "webpack" command in React.js?
Answer: C is the correct answer. The "webpack" command is a module bundler. 21) Which of the following is used to pass data to a component from outside in React.js?
Answer: C is the correct answer. Props are used to pass data to a component from outside in React.js. 22) What does ES6 stand for?
Answer: A is the correct option. ES6 stands for ECMAScript 6. ECMAScript was created to standardize JavaScript. ES6 is the 6th version of ECMAScript published in 2015. It is also known as ECMAScript 2015. 23) Which of the following function is used to change the state of the React.js component?
Answer: A is the correct option. The "this.setState" function is used to change the state of the React.js component. 24) Which of the following method refers to the parent class in React.js?
Answer: C is the correct answer. The super() method refers to the parent class. If you want to call the parent's constructor method and get access to the parent's properties and methods, you can achieve it by calling the super() method in the constructor. 25) What will happen if you render an input element with disabled = {false}?
Answer: C is the correct answer. If you render an input element with disabled = {false}, it will be rendered as enabled. 26) Which of the following function is called to render HTML to the web page in React?
Answer: A is the correct option. React renders HTML to the web page by using a function called ReactDOM.render(). 27) Which of the following lifecycle events React components have at the highest level?
Answer: D is the correct option. 28) Why is the usage of setState?
Answer: A is the correct option. 29) Which of the following best defines the "key" prop?
Answer: B is the correct answer. It is used to identify any new item in a list when re-rendering. It improves performance and efficiency also. 30) Which of the following method is not a part of ReactDOM?
Answer: A is the correct answer as ReactDOM.destroy() method is not a part of ReactDOM. ReactDOM provides the developers with an API containing the methods such as render(), findDOMNode(), unmountComponentAtNode(), hydrate(), and createPortal(). 31) How can you set a default value for an uncontrolled form field?
Answer: B is the correct option. We can set a default value for an uncontrolled form field by using the defaultValue property. 32) We can update the state in React.js by calling to setState() method. These calls are:
Answer: B is the correct answer. The call to setState() method in React.js is asynchronous, and multiple calls can be batched for better performance. 33) Which of the following statement is true for controlled components in React.js?
Answer: C is the correct option. For controlled components in React.js, the source of truth is a component state. 34) What changes would appear in the component as soon as the state of the React component is changed?
Answer: B is the correct answer. In React.js, as soon as the state is updated, the component re-renders itself. 35) Which of the following statement is true for uncontrolled components in React.js?
Answer: A is the correct answer. For uncontrolled components in React.js, the source of truth is component DOM. 36) In which of the following condition, the React.js Lifecycle method static getDerivedSateFromProps(props, state) is called?
Answer: C is the correct option. In React.js, the static getDerivedSateFromProps(props, state) is called in both cases when a component is created and when a component is updated. 37) What is the use of the create-react-app command in the React.js application?
Answer: B is the correct option. The create-react-app command in the React.js application is used to create a new React app. 38) What is true for the keys given to a list of elements in React?
Answer: B is the correct option. Keys given to the list of elements in React should be unique among the siblings only.
Next Topic#
|