Unions MCQs – Part 1

Timer: Off
Random: Off

1. What is a union in C programming?
ⓐ. A data structure that allows storing multiple elements of the same type
ⓑ. A data structure that allows storing multiple elements of different types
ⓒ. A function that performs bitwise operations
ⓓ. An array with a fixed size
2. How is memory allocated for a union in C?
ⓐ. Memory is allocated sequentially for each member of the union
ⓑ. Memory is allocated based on the largest member of the union
ⓒ. Memory is allocated dynamically during runtime
ⓓ. Memory is allocated based on the smallest member of the union
3. Which operator is used to access members of a union in C?
ⓐ. Dot operator (.)
ⓑ. Arrow operator (->)
ⓒ. Colon operator (:)
ⓓ. Underscore operator (_)
4. What happens when you modify one member of a union in C?
ⓐ. All other members are automatically updated
ⓑ. Only the modified member is updated
ⓒ. It causes a compilation error
ⓓ. The union becomes invalid
5. Which of the following statements about unions in C is true?
ⓐ. Unions cannot contain nested structures
ⓑ. Unions can only contain primitive data types
ⓒ. Unions are similar to structures but with stricter memory alignment rules
ⓓ. Unions cannot be passed as function arguments
6. What is the keyword used to define a union in C?
ⓐ. union
ⓑ. struct
ⓒ. typedef
ⓓ. unionize
7. Which of the following statements about union members is correct?
ⓐ. Union members cannot have different data types
ⓑ. Union members share the same memory location
ⓒ. Union members are always initialized to zero
ⓓ. Union members are accessed using the asterisk (*) operator
8. Why are unions used in C programming?
ⓐ. To simplify arithmetic operations
ⓑ. To allocate memory dynamically
ⓒ. To store multiple values of the same type
ⓓ. To save memory by sharing the same space for different data types
9. Which operator is used to find the size of a union in C?
ⓐ. sizeof
ⓑ. sizeof()
ⓒ. sizeof union
ⓓ. size()
10. Can unions in C contain arrays as members?
ⓐ. Yes, but only fixed-size arrays
ⓑ. No, unions cannot contain arrays
ⓒ. Yes, with any size of arrays
ⓓ. Yes, but only one-dimensional arrays
Subscribe
Notify of
guest
1000


1 Comment
Inline Feedbacks
View all comments
Joshi

I share your level of enthusiasm for the work you’ve produced. The sketch you’ve displayed is refined, and the material you’ve authored is impressive. Nevertheless, you seem anxious about the prospect of heading in a direction that could cause unease. I agree that you’ll be able to address this concern in a timely manner.

1
0
Join Discussionsx
()
x