Question 1 of 50
What is the primary building block of a React application?
A
DOM
B
Component
C
Package
D
Module
Not quite. Try another option.
Answer: Component
Components are the core building blocks of React applications, allowing developers to split the UI into independent, reusable pieces.
Question 2 of 50
Which convention should be followed when naming a React component?
A
snake_case
B
camelCase
C
PascalCase
D
kebab-case
Not quite. Try another option.
Answer: PascalCase
React components must start with a capital letter (PascalCase) so that React can distinguish them from native HTML tags.
Question 3 of 50
Which method is required to be defined in a React Class Component?
A
getInitialState
B
constructor
C
render
D
componentDidMount
Not quite. Try another option.
Answer: render
The render() method is the only required method in a class component, returning the JSX elements to be displayed.
Question 4 of 50
How do you define a Functional Component in React?
A
class MyComponent extends React.Component
B
React.createClass({ ... })
C
function MyComponent() { return <div />; }
D
const MyComponent = new Component()
Not quite. Try another option.
Answer: function MyComponent() { return <div />; }
Functional components are simply JavaScript functions that return JSX.
Question 5 of 50
What is the React Virtual DOM?
A
A database for storing state
B
A lightweight JavaScript representation of the real DOM
C
A CSS processing engine
D
A direct copy of the browser's DOM
Not quite. Try another option.
Answer: A lightweight JavaScript representation of the real DOM
The Virtual DOM is a programming concept where a virtual representation of the UI is kept in memory and synced with the 'real' DOM.
Question 6 of 50
What is the process of updating the DOM to match the Virtual DOM called?
A
Transpilation
B
Reconciliation
C
Compiling
D
Rendering
Not quite. Try another option.
Answer: Reconciliation
Reconciliation is the process through which React updates the DOM by comparing the new Virtual DOM with the previous one.
Question 7 of 50
What does 'Props' stand for in React?
A
Prototypes
B
Propositions
C
Proper HTML
D
Properties
Not quite. Try another option.
Answer: Properties
Props stands for properties, which are arguments passed into React components.
Question 8 of 50
Are React Props mutable?
A
Only inside class components
B
No, they are read-only
C
Only inside functional components
D
Yes, always
Not quite. Try another option.
Answer: No, they are read-only
Props are read-only (immutable) from the perspective of the child component receiving them. A component must never modify its own props.
Question 9 of 50
How do you access props in a Class Component?
A
getProps().name
B
props.name
C
this.props.name
D
super.name
Not quite. Try another option.
Answer: this.props.name
In a class component, props are accessed via 'this.props'.
Question 10 of 50
Which attribute is used to assign a CSS class in React JSX?
A
class
B
className
C
styleClass
D
cssClass
Not quite. Try another option.
Answer: className
Since 'class' is a reserved keyword in JavaScript, React uses 'className' to define CSS classes.
Question 11 of 50
What is the data type of the 'style' attribute when using inline styling in React?
A
JavaScript Object
B
String
C
Array
D
CSS File
Not quite. Try another option.
Answer: JavaScript Object
Inline styles in React are passed as a JavaScript object, not a string.
Question 12 of 50
How is the CSS property 'background-color' written in React inline styles?
A
Background-Color
B
bgColor
C
backgroundColor
D
background-color
Not quite. Try another option.
Answer: backgroundColor
React uses camelCase for inline style properties to match the JavaScript DOM API.
Question 13 of 50
What is the primary advantage of using CSS Modules?
A
It removes the need for CSS
B
It allows writing CSS in PHP
C
It scopes CSS classes locally to the component
D
It automatically adds TailwindCSS
Not quite. Try another option.
Answer: It scopes CSS classes locally to the component
CSS Modules generate unique class names, ensuring that styles are scoped locally to the component and do not conflict globally.
Question 14 of 50
Which file extension is typically used for CSS Modules?
A
.module.css
B
.style.js
C
.js.css
D
.css
Not quite. Try another option.
Answer: .module.css
React recognizes files ending in '.module.css' as CSS Modules automatically.
Question 15 of 50
What is TailwindCSS?
A
A component library like MaterialUI
B
A CSS-in-JS library
C
A utility-first CSS framework
D
A React state manager
Not quite. Try another option.
Answer: A utility-first CSS framework
TailwindCSS is a utility-first CSS framework that provides low-level utility classes to build custom designs.
Question 16 of 50
How do you pass a prop named 'color' with value 'red' to a component 'Button'?
A
<Button>red</Button>
B
<Button prop:color='red' />
C
Button.color = 'red'
D
<Button color='red' />
Not quite. Try another option.
Answer: <Button color='red' />
Props are passed to components using syntax similar to HTML attributes.
Question 17 of 50
In a functional component, how do you access props passed as an argument?
A
getProps()
B
arguments[0]
C
props
D
this.props
Not quite. Try another option.
Answer: props
Functional components accept a single argument, usually named 'props', which contains the data passed to the component.
Question 18 of 50
Can a functional component use State?
A
Yes, using the useState hook
B
Only if converted to a Class
C
Yes, using this.state
D
No, never
Not quite. Try another option.
Answer: Yes, using the useState hook
With the introduction of React Hooks (specifically useState), functional components can manage state.
Question 19 of 50
What keyword is used to inherit from React.Component in a class component?
A
uses
B
implements
C
inherits
D
extends
Not quite. Try another option.
Answer: extends
Class components are defined using ES6 classes that 'extend' React.Component.
Question 20 of 50
Why is the 'key' prop important in lists?
A
It sorts the list alphabetically
B
It helps React identify which items have changed, added, or removed
C
It styles the list items
D
It is required for CSS Modules
Not quite. Try another option.
Answer: It helps React identify which items have changed, added, or removed
Keys help the reconciliation algorithm identify elements uniquely to optimize rendering performance.
Question 21 of 50
Which of the following is NOT a valid way to style a React component?
A
CSS Stylesheets
B
Direct DOM manipulation of style attribute
C
CSS Modules
D
Inline Styling
Not quite. Try another option.
Answer: Direct DOM manipulation of style attribute
While technically possible via refs, direct DOM manipulation is contrary to React's declarative paradigm and is not a standard styling method.
Question 22 of 50
In TailwindCSS, how would you apply a red text color?
A
style={{color: 'red'}}
B
text-red-500
C
color: red
D
font-red
Not quite. Try another option.
Answer: text-red-500
Tailwind uses utility classes like 'text-red-500' to apply styles directly in the className.
Question 23 of 50
What is the correct syntax to import a CSS file 'App.css' into 'App.js'?
A
import './App.css';
B
include 'App.css';
C
require('App.css');
D
using 'App.css';
Not quite. Try another option.
Answer: import './App.css';
Standard CSS files are imported directly using the ES6 import syntax with the relative path.
Question 24 of 50
In React, what replaces the HTML 'for' attribute in labels?
A
ref
B
forId
C
labelFor
D
htmlFor
Not quite. Try another option.
Answer: htmlFor
'for' is a reserved keyword in JavaScript (for loops), so React uses 'htmlFor'.
Question 25 of 50
What allows React to be faster than traditional DOM manipulation?
A
It runs on the GPU
B
It compresses HTML files
C
It uses the Virtual DOM to minimize direct DOM access
D
It does not use JavaScript
Not quite. Try another option.
Answer: It uses the Virtual DOM to minimize direct DOM access
React computes the minimal set of changes needed using the Virtual DOM and applies them in a batch, which is faster than frequent direct DOM updates.
Question 26 of 50
How do you use a default value for a prop in a functional component?
A
Use global variables
B
It is not possible
C
Check if it is null inside render
D
Define it in defaultProps or destructure with a default value
Not quite. Try another option.
Answer: Define it in defaultProps or destructure with a default value
You can use component.defaultProps or modern ES6 destructuring: function Comp({ name = 'Guest' }).
Question 27 of 50
When using a Class Component, where do you typically initialize state?
A
In the return statement
B
In the render method
C
In the constructor
D
In the CSS file
Not quite. Try another option.
Answer: In the constructor
State is traditionally initialized in the constructor using this.state = { ... }.
Question 28 of 50
What is 'children' in React props?
A
The subclass of a component
B
An array of all components in the app
C
A method to create new components
D
The child components defined within the opening and closing tags
Not quite. Try another option.
Answer: The child components defined within the opening and closing tags
props.children represents the content included between the opening and closing tags of a component.
Question 29 of 50
Which configuration file is generated when initializing TailwindCSS?
A
tailwind.json
B
css.config.json
C
style.config.js
D
tailwind.config.js
Not quite. Try another option.
Answer: tailwind.config.js
Running npx tailwindcss init creates a tailwind.config.js file for customization.
Question 30 of 50
Can a React component return null?
A
Only in development mode
B
No, it throws an error
C
Yes, it renders nothing
D
Only in class components
Not quite. Try another option.
Answer: Yes, it renders nothing
Returning null from a component tells React to render nothing for that component.
Question 31 of 50
When using CSS Modules, how do you apply a class named 'header'?
A
className={styles.header}
B
class='header'
C
style={header}
D
className='header'
Not quite. Try another option.
Answer: className={styles.header}
CSS Modules require importing the styles object (usually named styles) and accessing the class name as a property.
Question 32 of 50
What is the main difference between Functional and Class components regarding the this keyword?
A
There is no difference
B
Functional components use this extensively
C
Class components do not use this
D
Functional components do not use this to access props or state
Not quite. Try another option.
Answer: Functional components do not use this to access props or state
Functional components are plain functions and do not have instances, so they don't use this. Class components rely on this.
Question 33 of 50
Which tool is commonly used to install TailwindCSS in a React project?
A
pip
B
maven
C
composer
D
npm or yarn
Not quite. Try another option.
Answer: npm or yarn
TailwindCSS is a Node package and is installed using Node Package Managers like npm or yarn.
Question 34 of 50
In the Diffing Algorithm, what happens if the root elements of two trees are different types?
A
React throws an error
B
React keeps the old DOM and appends the new one
C
React tears down the old tree and builds the new tree from scratch
D
React updates only the attributes
Not quite. Try another option.
Answer: React tears down the old tree and builds the new tree from scratch
If the root elements are different (e.g., <div> to <span>), React assumes the entire subtree has changed and rebuilds it completely.
Question 35 of 50
Can you use multiple CSS classes in the className attribute?
A
Yes, using an array
B
No, only one class is allowed
C
Yes, separated by spaces
D
Yes, separated by commas
Not quite. Try another option.
Answer: Yes, separated by spaces
Like HTML, multiple classes can be assigned in a single string separated by spaces.
Question 36 of 50
What syntax allows you to render a component inside another component?
A
new ChildComponent()
B
import ChildComponent
C
render(ChildComponent)
D
<ChildComponent />
Not quite. Try another option.
Answer: <ChildComponent />
React components are composed by including the child component's JSX tag inside the parent's return statement.
Question 37 of 50
What is a 'Stateless Functional Component'?
A
A functional component that does not use hooks to manage state
B
A slow component
C
A component without props
D
A component that cannot render HTML
Not quite. Try another option.
Answer: A functional component that does not use hooks to manage state
Before hooks, functional components were purely presentational and stateless. The term refers to a function that only receives props and renders UI.
Question 38 of 50
If you want to apply dynamic inline styles based on a variable isActive, which is correct?
A
css={ isActive ? 'red' : 'blue' }
B
style='color: red'
C
style={{ color: isActive ? 'red' : 'blue' }}
D
className={isActive}
Not quite. Try another option.
Answer: style={{ color: isActive ? 'red' : 'blue' }}
Inline styles accept an object, and ternary operators are commonly used within the object values for conditional styling.
Question 39 of 50
Which feature allows you to pass data from a parent to a child component?
A
Ref
B
Props
C
Context
D
State
Not quite. Try another option.
Answer: Props
Props are the standard mechanism for passing data down the component tree from parent to child.
Question 40 of 50
Which file contains the directives @tailwind base;, @tailwind components;, and @tailwind utilities;?
A
index.html
B
App.js
C
The main CSS entry file (e.g., index.css)
D
package.json
Not quite. Try another option.
Answer: The main CSS entry file (e.g., index.css)
These directives inject Tailwind's styles and are placed in the project's global CSS file.
Question 41 of 50
How does React handle boolean values in JSX interpolation {true}?
A
It throws an error
B
It renders nothing
C
It renders a checkbox
D
It renders 'true'
Not quite. Try another option.
Answer: It renders nothing
Booleans, null, and undefined are valid children in React but they do not render anything to the DOM.
Question 42 of 50
What is the correct way to export a component as the default export?
A
export default ComponentName;
B
return ComponentName;
C
module.export = ComponentName;
D
export ComponentName;
Not quite. Try another option.
Answer: export default ComponentName;
The ES6 syntax for a default export is export default VariableName;.
Question 43 of 50
When using inline styles, which unit is assumed for unitless numbers on properties like width?
A
%
B
em
C
px (pixels)
D
rem
Not quite. Try another option.
Answer: px (pixels)
React automatically appends 'px' to unitless numbers for specific properties like width, height, margin, etc.
Question 44 of 50
Can props contain functions?
A
No, only strings and numbers
B
Only if the function is static
C
Yes, to handle events or callbacks
D
Only in Class components
Not quite. Try another option.
Answer: Yes, to handle events or callbacks
Props can hold any JavaScript value, including functions, which allows child components to communicate back to parents.
Question 45 of 50
What is the purpose of the super(props) call in a Class component constructor?
A
To initialize the state
B
To call the parent class constructor and bind this.props
C
To import CSS
D
To render the component
Not quite. Try another option.
Answer: To call the parent class constructor and bind this.props
In JavaScript classes, super calls the parent constructor. In React, passing props ensures this.props is set in the constructor.
Question 46 of 50
Which of the following is a benefit of Functional Components over Class Components?
A
They have more lifecycle methods
B
They are more verbose
C
They are generally easier to read and test, and require less boilerplate
D
They support inheritance
Not quite. Try another option.
Answer: They are generally easier to read and test, and require less boilerplate
Functional components reduce the boilerplate code (like constructors and this binding) associated with classes.
Question 47 of 50
In the context of Virtual DOM, what is 'Batch Update'?
A
Grouping multiple state updates into a single re-render for performance
B
Updating the database in batches
C
Downloading multiple files
D
Updating all components at once every second
Not quite. Try another option.
Answer: Grouping multiple state updates into a single re-render for performance
React groups multiple state updates that occur in event handlers to trigger a single re-render/reconciliation cycle.
Question 48 of 50
If a prop is passed to a component but not defined in the component's logic, what happens?
A
React throws a warning
B
The app crashes
C
It appears in the DOM as an attribute automatically
D
The prop is ignored
Not quite. Try another option.
Answer: The prop is ignored
If the component logic doesn't use the prop, it is simply ignored. It doesn't break the app or appear in the DOM unless explicitly rendered.
Question 49 of 50
Can you use standard CSS and TailwindCSS in the same project?
A
Yes, they can coexist
B
Only if you use inline styles
C
No, they conflict
D
Only in separate pages
Not quite. Try another option.
Answer: Yes, they can coexist
TailwindCSS generates standard CSS classes. You can use them alongside your own custom CSS files without issue.
Question 50 of 50
Which syntax is used to destructure props in a functional component parameter?
A
function Comp(props) { const name = props.name }
B
function Comp({ name, age }) { ... }
C
function Comp(name, age) { ... }
D
function Comp([name, age]) { ... }
Not quite. Try another option.
Answer: function Comp({ name, age }) { ... }
Object destructuring inside the function parameter list ({ name, age }) is the standard cleaner way to access specific props.