Unit 2 - Practice Quiz

INT252 50 Questions
0 Correct 0 Wrong 50 Left
0/50

1 What is the primary building block of a React application?

A. Package
B. Module
C. Component
D. DOM

2 Which convention should be followed when naming a React component?

A. kebab-case
B. snake_case
C. camelCase
D. PascalCase

3 Which method is required to be defined in a React Class Component?

A. componentDidMount
B. render
C. constructor
D. getInitialState

4 How do you define a Functional Component in React?

A. class MyComponent extends React.Component
B. const MyComponent = new Component()
C. function MyComponent() { return <div />; }
D. React.createClass({ ... })

5 What is the React Virtual DOM?

A. A database for storing state
B. A direct copy of the browser's DOM
C. A CSS processing engine
D. A lightweight JavaScript representation of the real DOM

6 What is the process of updating the DOM to match the Virtual DOM called?

A. Compiling
B. Rendering
C. Reconciliation
D. Transpilation

7 What does 'Props' stand for in React?

A. Prototypes
B. Propositions
C. Proper HTML
D. Properties

8 Are React Props mutable?

A. Only inside functional components
B. No, they are read-only
C. Yes, always
D. Only inside class components

9 How do you access props in a Class Component?

A. this.props.name
B. props.name
C. super.name
D. getProps().name

10 Which attribute is used to assign a CSS class in React JSX?

A. class
B. cssClass
C. styleClass
D. className

11 What is the data type of the 'style' attribute when using inline styling in React?

A. Array
B. JavaScript Object
C. String
D. CSS File

12 How is the CSS property 'background-color' written in React inline styles?

A. bgColor
B. Background-Color
C. backgroundColor
D. background-color

13 What is the primary advantage of using CSS Modules?

A. It scopes CSS classes locally to the component
B. It automatically adds TailwindCSS
C. It removes the need for CSS
D. It allows writing CSS in PHP

14 Which file extension is typically used for CSS Modules?

A. .js.css
B. .css
C. .module.css
D. .style.js

15 What is TailwindCSS?

A. A React state manager
B. A CSS-in-JS library
C. A utility-first CSS framework
D. A component library like MaterialUI

16 How do you pass a prop named 'color' with value 'red' to a component 'Button'?

A. <Button prop:color='red' />
B. <Button color='red' />
C. <Button>red</Button>
D. Button.color = 'red'

17 In a functional component, how do you access props passed as an argument?

A. props
B. this.props
C. arguments[0]
D. getProps()

18 Can a functional component use State?

A. Only if converted to a Class
B. Yes, using this.state
C. Yes, using the useState hook
D. No, never

19 What keyword is used to inherit from React.Component in a class component?

A. inherits
B. extends
C. implements
D. uses

20 Why is the 'key' prop important in lists?

A. It helps React identify which items have changed, added, or removed
B. It styles the list items
C. It sorts the list alphabetically
D. It is required for CSS Modules

21 Which of the following is NOT a valid way to style a React component?

A. Inline Styling
B. CSS Modules
C. CSS Stylesheets
D. Direct DOM manipulation of style attribute

22 In TailwindCSS, how would you apply a red text color?

A. font-red
B. style={{color: 'red'}}
C. text-red-500
D. color: red

23 What is the correct syntax to import a CSS file 'App.css' into 'App.js'?

A. using 'App.css';
B. import './App.css';
C. include 'App.css';
D. require('App.css');

24 In React, what replaces the HTML 'for' attribute in labels?

A. forId
B. labelFor
C. htmlFor
D. ref

25 What allows React to be faster than traditional DOM manipulation?

A. It uses the Virtual DOM to minimize direct DOM access
B. It compresses HTML files
C. It does not use JavaScript
D. It runs on the GPU

26 How do you use a default value for a prop in a functional component?

A. It is not possible
B. Check if it is null inside render
C. Use global variables
D. Define it in defaultProps or destructure with a default value

27 When using a Class Component, where do you typically initialize state?

A. In the return statement
B. In the CSS file
C. In the constructor
D. In the render method

28 What is 'children' in React props?

A. The subclass of a component
B. A method to create new components
C. The child components defined within the opening and closing tags
D. An array of all components in the app

29 Which configuration file is generated when initializing TailwindCSS?

A. style.config.js
B. css.config.json
C. tailwind.config.js
D. tailwind.json

30 Can a React component return null?

A. Only in class components
B. Only in development mode
C. No, it throws an error
D. Yes, it renders nothing

31 When using CSS Modules, how do you apply a class named 'header'?

A. className='header'
B. className={styles.header}
C. class='header'
D. style={header}

32 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. Functional components do not use this to access props or state
D. Class components do not use this

33 Which tool is commonly used to install TailwindCSS in a React project?

A. composer
B. npm or yarn
C. maven
D. pip

34 In the Diffing Algorithm, what happens if the root elements of two trees are different types?

A. React keeps the old DOM and appends the new one
B. React tears down the old tree and builds the new tree from scratch
C. React updates only the attributes
D. React throws an error

35 Can you use multiple CSS classes in the className attribute?

A. Yes, using an array
B. Yes, separated by commas
C. Yes, separated by spaces
D. No, only one class is allowed

36 What syntax allows you to render a component inside another component?

A. import ChildComponent
B. <ChildComponent />
C. render(ChildComponent)
D. new ChildComponent()

37 What is a 'Stateless Functional Component'?

A. A component that cannot render HTML
B. A slow component
C. A functional component that does not use hooks to manage state
D. A component without props

38 If you want to apply dynamic inline styles based on a variable isActive, which is correct?

A. style={{ color: isActive ? 'red' : 'blue' }}
B. css={ isActive ? 'red' : 'blue' }
C. className={isActive}
D. style='color: red'

39 Which feature allows you to pass data from a parent to a child component?

A. Ref
B. Props
C. State
D. Context

40 Which file contains the directives @tailwind base;, @tailwind components;, and @tailwind utilities;?

A. App.js
B. index.html
C. package.json
D. The main CSS entry file (e.g., index.css)

41 How does React handle boolean values in JSX interpolation {true}?

A. It renders a checkbox
B. It throws an error
C. It renders nothing
D. It renders 'true'

42 What is the correct way to export a component as the default export?

A. module.export = ComponentName;
B. export ComponentName;
C. export default ComponentName;
D. return ComponentName;

43 When using inline styles, which unit is assumed for unitless numbers on properties like width?

A. px (pixels)
B. %
C. rem
D. em

44 Can props contain functions?

A. Only if the function is static
B. No, only strings and numbers
C. Only in Class components
D. Yes, to handle events or callbacks

45 What is the purpose of the super(props) call in a Class component constructor?

A. To call the parent class constructor and bind this.props
B. To render the component
C. To import CSS
D. To initialize the state

46 Which of the following is a benefit of Functional Components over Class Components?

A. They are more verbose
B. They are generally easier to read and test, and require less boilerplate
C. They have more lifecycle methods
D. They support inheritance

47 In the context of Virtual DOM, what is 'Batch Update'?

A. Updating all components at once every second
B. Updating the database in batches
C. Grouping multiple state updates into a single re-render for performance
D. Downloading multiple files

48 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 prop is ignored
C. It appears in the DOM as an attribute automatically
D. The app crashes

49 Can you use standard CSS and TailwindCSS in the same project?

A. Yes, they can coexist
B. Only if you use inline styles
C. Only in separate pages
D. No, they conflict

50 Which syntax is used to destructure props in a functional component parameter?

A. function Comp({ name, age }) { ... }
B. function Comp(props) { const name = props.name }
C. function Comp(name, age) { ... }
D. function Comp([name, age]) { ... }