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