🔹MCQs Of Class 4: Props in Depth

Rashmi Mishra
0

 

 ðŸ”¹MCQs Of Class 4

Props in Depth


🔹 Section A: Basics of Props (1–10)

1.   What are props in React?
A. A built-in function
B. Arguments passed to components
C. Special CSS styles
D. None of the above
️ Answer: B

2.   Props in React are:
A. Mutable
B. Read-only
C. Functions
D. Classes
️ Answer: B

3.   Props are passed from:
A. Child to Parent
B. Component to DOM
C. Parent to Child
D. DOM to Component
️ Answer: C

4.   Which keyword is used to access props in a functional component?
A. this.props
B. state
C. props
D. getProps()
️ Answer: C

5.   What does this syntax represent: <Student name="Ravi" />?
A. State declaration
B. Component function
C. Prop being passed
D. CSS application
️ Answer: C

6.   Props can be:
A. Strings
B. Objects
C. Arrays
D. All of the above
️ Answer: D

7.   Which of the following is NOT true about props?
A. Props are immutable
B. Props help reuse components
C. Props can be updated in a child component
D. Props allow data to flow from parent to child
️ Answer: C

8.   How do you define a prop in a functional component?
A. function Comp(props) {}
B. function Comp(state) {}
C. function Comp() {}
D. props = Comp()
️ Answer: A

9.   Which one of the following allows the use of props in JSX?
A. props=>value
B. {props.name}
C. [props.name]
D. {{props.name}}
️ Answer: B

10.                   What happens if a required prop is not passed?
A. Component throws an error
B. Default value is used
C. React crashes
D. Component shows undefined
️ Answer: D


🔹 Section B: Props with Objects & Arrays (11–25)

11.                   Which of these is the correct way to pass an object as a prop?
A. data="name: 'Raj'"
B. data={{name: "Raj"}}
C. data=(name: "Raj")
D. data.name="Raj"
️ Answer: B

12.                   How do you access the name property inside the student object prop?
A. props.student
B. props.student[name]
C. props.student.name
D. props.name.student
️ Answer: C

13.                   How do you loop through an array prop to display each item?
A. for(item in props.arr)
B. map(item => item)
C. props.arr.map()
D. loop(props.arr)
️ Answer: C

14.                   What is the key attribute used for in list rendering?
A. Makes items draggable
B. Identifies elements uniquely
C. Adds props
D. It’s not required
️ Answer: B

15.                   Which of the following is a valid prop for an image?
A. imgPath
B. src
C. alt
D. Both B and C
️ Answer: D

16.                   Can you pass a function as a prop?
A. Yes
B. No
️ Answer: A

17.                   In JSX, arrays should be rendered using:
A. forEach
B. for loop
C. map()
D. filter()
️ Answer: C

18.                   What happens if you forget the key prop in an array rendering?
A. Nothing happens
B. React gives a warning
C. Error appears
D. The component doesn’t render
️ Answer: B

19.                   What is the correct syntax to pass an array as a prop?
A. arr="1,2,3"
B. arr={1,2,3}
C. arr={[1,2,3]}
D. arr=(1,2,3)
️ Answer: C

20.                   How do you pass a JSON object as a prop?
A. data="{...}"
B. data='{}'
C. data={{name: "Raj"}}
D. data={"name":"Raj"}
️ Answer: C

21.                   Which type of prop is best for displaying a list of items?
A. Boolean
B. Number
C. Array
D. String
️ Answer: C

22.                   What will {props.items[0]} access?
A. First prop
B. Last prop
C. First item of array items
D. All items
️ Answer: C

23.                   How should you uniquely identify each element in a rendered list?
A. id
B. value
C. key
D. name
Answer: C

24.                   What happens if the key prop is not unique?
A. React works fine
B. It may cause bugs during re-render
C. Duplicate output
D. Elements are hidden
️ Answer: B

25.                   When should you use array props?
A. For static content only
B. For repeating similar components
C. For error handling
D. To reduce memory
️ Answer: B


🔹 Section C: Props with Children (26–35)

26.                   What is props.children used for?
A. To display component children
B. To track child processes
C. To store global props
D. To show a modal
️ Answer: A

27.                   Which tag passes children prop?
A. <Component />
B. <Component></Component>
C. <Component /> <Child />
D. <Component><Component />
️ Answer: B

28.                   In which case is props.children undefined?
A. When passed an image
B. When no content is nested
C. When used in class components
D. Always
️ Answer: B

29.                   How do you display nested JSX inside a component?
A. Use props.content
B. Use this.props.children
C. Use props.children
D. Use component.children
️ Answer: C

30.                   Which of these is a correct use of children prop?
A. <Card>Content</Card>
B. <Card child="Content" />
C. <Card :children="Content" />
D. <Card />Content</Card>
️ Answer: A

31.                   How many children can props.children hold?
A. One only
B. Multiple
C. None
D. Two only
️ Answer: B

32.                   What is the data type of props.children?
A. Array
B. Object
C. JSX or string
D. It varies
️ Answer: D

33.                   To wrap multiple elements in a component using children, use:
A. <div>
B. React.Fragment
C. Both
D. None
️ Answer: C

34.                   How do you insert props and children in the same component?
A. props.children and props.name
B. Use this.props()
C. Wrap with {}
D. You can't
️ Answer: A

35.                   Can props.children be another component?
A. Yes
B. No
️ Answer: A


🔹 Section D: Practical Usage (36–50)

36.                   Which component displays a student card with name, grade, and image?
A. StudentForm
B. StudentCard
C. StudentList
D. GradeCard
️ Answer: B

37.                   In JSX, how do you render a prop named title?
A. props.title()
B. props[title]
C. {props.title}
D. title
️ Answer: C

38.                   How do you avoid repetition when displaying 5 student cards?
A. Copy code
B. Use map() with array
C. Use if-else
D. Use for loop
️ Answer: B

39.                   Which prop is commonly used in image rendering?
A. path
B. src
C. img
D. file
️ Answer: B

40.                   How do you pass a numeric value as a prop?
A. value="10"
B. value={10}
C. value: 10
D. value=10
️ Answer: B

41.                   Props help in:
A. Creating global state
B. Reusing components
C. Updating DOM
D. Changing URLs
️ Answer: B

42.                   Props must be passed using:
A. HTML syntax
B. JSX syntax
C. Inline JS
D. JavaScript classes
️ Answer: B

43.                   Which one is not a valid prop type?
A. String
B. Boolean
C. JSX
D. Database
️ Answer: D

44.                   Props are similar to:
A. Variables
B. Parameters in functions
C. CSS
D. Routes
️ Answer: B

45.                   Which one renders the image correctly from a prop?
A. <img src={props.image} />
B. <img>{props.image}</img>
C. img={props.image}
D. <img file={props.image} />
️ Answer: A

46.                   If a prop is not passed, its value is:
A. Null
B. Empty
C. Undefined
D. 0
️ Answer: C

47.                   Props in React enable:
A. One-way data binding
B. Two-way data binding
C. Global state
D. DOM control
️ Answer: A

48.                   Which of these keywords is NOT related to props?
A. key
B. value
C. this
D. props
️ Answer: C

49.                   Props can be used inside:
A. Functions only
B. Components only
C. Both
D. Nowhere
️ Answer: C

50.                   What is the purpose of using props?
A. To style components
B. To share data between components
C. To fetch data from API
D. To create hooks
️ Answer: B

 

Tags

Post a Comment

0Comments

Post a Comment (0)