Question 1
What does the following line do in a React file?
import React from 'react';
Runs the React application
Imports the React library to use JSX and components
Imports only hooks like useState and useEffect
Initializes the DOM for rendering
Question 2
React follows which type of architecture for building UIs?
Template-driven architecture
MVC (Model-View-Controller) architecture
Component-based architecture
Layered architecture
Question 3
Which is the correct way to pass a prop named username with value "Anil" to the Greet component?
<Greet username="Anil" />
<Greet {username="Anil"} />
<Greet props.username="Anil" />
<Greet name=username />
Question 4
Identify the output of this component:
function Greeting() {
return <h1>Hello, welcome to React!</h1>;
}
Displays nothing
Displays "Hello, World!"
Displays "Hello, welcome to React!"
Causes a compilation error
Question 5
If multiple components need the same state data, what is the recommended approach?
Duplicate the state in each component
Pass state as props from their nearest common ancestor
Use CSS variables to share data
Avoid using state entirely
Question 6
What is the default development server port when running a Vite React app?
3000
5000
5173
8080
Question 7
vite create react-app my-app
npm create vite@latest my-app --template react
npx create-react-app my-app
npm install react-vite
Question 8
In React, what is the main difference between props and state?
Props are mutable, state is immutable
Props are passed from parent, state is managed within the component
Both are the same, just used differently
State can be shared across components, props cannot
Question 9
What is the purpose of the ReactDOM.render method?
To manage application state
To compile JSX into JavaScript
To render a React component into the DOM
To define the Virtual DOM
Question 10
What will be the output of this React code?
import React from 'react';
import ReactDOM from 'react-dom';
function App() {
const greeting = "Hello";
return <h1>{greeting} World</h1>;
}
ReactDOM.render(<App />, document.getElementById('root'));
Hello World
{greeting} World
"Hello World"
Error
There are 10 questions to complete.