Sample Quizzes For Preparation: User-Defined Data Types
A2 Level Computer Science – Topic 13.1: User-defined Data Types Quiz
Question 1
Which of the following best describes an enumerated type?
A. A data structure that holds multiple types in an ordered list
B. A user-defined data type that consists of named constant values
C. A loop that assigns integer values to a set
D. A collection of key-value pairs
Question 2
Why are enumerated types useful in programming?
A. They allow you to define dynamic arrays
B. They reduce memory usage significantly
C. They improve code readability and restrict invalid data
D. They are easier to compile than other types
Question 3
Which of the following is a valid declaration of a pointer type?
A. TYPE name = POINTER OF Node
B. TYPE name = ^Node
C. TYPE NodePointer -> Node
D. POINTER name TO Node
Question 4
What is the main advantage of using pointers?
A. They reduce code execution time
B. They allow direct communication with the operating system
C. They allow the creation of dynamic data structures like linked lists
D. They can only be used in high-level languages
Question 5
Which of the following correctly defines a Record
type for a book?
A. TYPE Book = (Title, Author, Pages)
B. TYPE Book = [Title: STRING, Author: STRING, Pages: INTEGER]
C. TYPE Book = RECORD Title: STRING; Author: STRING; Pages: INTEGER END RECORD
D. TYPE Book = CLASS Title, Author, Pages
Question 6
What distinguishes a composite data type from a non-composite data type?
A. Composite types can only store numeric data
B. Composite types contain multiple values or types under one structure
C. Non-composite types use more memory
D. Non-composite types cannot be user-defined
Question 7
Which of the following is NOT a composite data type?
A. Record
B. Set
C. Enumerated
D. Class
Question 8
Which operation is valid for Set
data types?
A. Multiplication
B. Union
C. Exponentiation
D. Modulo
Question 9
Which of the following is a valid use of a Set
data type?
A. Representing an ordered list of books
B. Representing unique subjects a student is taking
C. Representing a person’s name
D. Representing an image pixel grid
Question 10
What is the main purpose of defining classes as user-defined types?
A. To allow fixed arrays
B. To store characters and integers only
C. To encapsulate both data and related behavior
D. To reduce RAM usage in low-level programs
Question 11
Which user-defined type is most appropriate for modelling a traffic light with states Red, Yellow, and Green?
A. Record
B. Set
C. Class
D. Enumerated type
Question 12
What keyword is commonly used to define an enumerated type in Pascal-like pseudocode?
A. SET
B. RECORD
C. CLASS
D. TYPE
Question 13
What is the output of the following?
TYPE Color = (Red, Green, Blue)
VAR c: Color
c := Green
WRITE(c)
A. 0
B. 1
C. Green
D. Error
Question 14
What does a pointer variable store?
A. The value of another variable
B. The address of another variable
C. The size of another variable
D. The type of another variable
Question 15
Which feature is unique to class/object user-defined types among all others listed?
A. Ability to define memory locations
B. Ability to create structured data
C. Ability to encapsulate methods along with data
D. Ability to hold integer values only
Marking Key and Explanations – A2 Computer Science: User-defined Data Types Quiz
Q1. B. A user-defined data type that consists of named constant values
Explanation: Enumerated types (enums) assign names to constant integral values, improving readability.
Q2. C. They improve code readability and restrict invalid data
Explanation: Enums restrict variable values to a limited set of identifiers, reducing errors.
Q3. A. TYPE name = POINTER OF Node
Explanation: This is the standard pseudocode declaration for a pointer type referencing Node
.
Q4. C. They allow the creation of dynamic data structures like linked lists
Explanation: Pointers support dynamic memory allocation needed in structures like trees, graphs, etc.
Q5. C. TYPE Book = RECORD Title: STRING; Author: STRING; Pages: INTEGER END RECORD
Explanation: This is the proper format for defining a record type in pseudocode.
Q6. B. Composite types contain multiple values or types under one structure
Explanation: Composite types (e.g., record, class) can hold multiple components of varying types.
Q7. C. Enumerated
Explanation: Enumerated types are non-composite; they consist of single named constants.
Q8. B. Union
Explanation: Sets support operations like union, intersection, and difference.
Q9. B. Representing unique subjects a student is taking
Explanation: Sets store unique values and are ideal for representing non-repeating items.
Q10. C. To encapsulate both data and related behavior
Explanation: Classes combine attributes (data) and methods (behavior), unlike other user-defined types.
Q11. D. Enumerated type
Explanation: A traffic light has a fixed set of values, perfect for enumeration.
Q12. D. TYPE
Explanation: TYPE
is the pseudocode keyword used to define any user-defined type.
Q13. C. Green
Explanation: The WRITE
statement prints the identifier name of the enum value assigned.
Q14. B. The address of another variable
Explanation: Pointers store memory addresses, allowing indirect access to data.
Q15. C. Ability to encapsulate methods along with data
Explanation: Only classes (objects) can define both data and procedures (methods), allowing encapsulation.