Match the following with respect to C++ data types : List – I List – II a.…
2012
Match the following with respect to C++ data types :
List – I | List – II |
|---|---|
a. User defined type | 1. Qualifier |
b. Built-in type | 2. Union |
c. Derived type | 3. Void |
d. Long double | 4. Pointer |
Code :
a | b | c | d |
|---|
Answer: A. 2 3 4 1 — Concept. C++ sorts every type into one of three families. Fundamental (built-in) types are supplied by the language itself — int, char, float, double, bool…
- A.
2
3
4
1
- B.
3
1
4
2
- C.
4
1
2
3
- D.
3
4
1
2
Attempted by 17 students.
Show answer & explanation
Correct answer: A
Concept. C++ sorts every type into one of three families. Fundamental (built-in) types are supplied by the language itself — int, char, float, double, bool and void. Derived types are built out of an already existing type and declare no members of their own — arrays, pointers, references and functions. User-defined types are declared by the programmer together with their own members — class, struct, union and enum. Alongside these families C++ has keywords that are written in front of a base type instead of naming a type by themselves: the size/sign specifiers signed, unsigned, short and long, and the cv-qualifiers const and volatile. Classic exam textbooks gather all of these under the single heading "qualifier", and it is that broader sense this item uses.
Application to this item.
a. User defined type — a
unionis written by the programmer with its own member list, exactly as aclass,structorenumis, so it falls in the user-defined family. So a takes 2.b. Built-in type —
voidis defined by the language, not by the programmer; it names "no value" for a function return type and yields the generic pointer typevoid*. So b takes 3.c. Derived type — a pointer type
T*is constructed from an existing type T and introduces no new members, which is exactly the definition of a derived type (arrays, references and functions are derived for the same reason). So c takes 4.d. Long double — the question here is which heading the word
longbelongs under. It is written in front of the base typedoubleas a size specifier, so on this taxonomy the entry sits under the qualifier heading rather than under the user-defined or derived families. (Strictly, the C++ standard countslong doubleitself among the fundamental floating-point types; the exam’s List-II simply has no "fundamental type" slot left, because void already occupies it.) So d takes 1.
Cross-check.
A union cannot be a derived type: a derived type adds no members of its own, while a union declares its members.
Void cannot be user-defined: no programmer declaration brings it into existence — the language defines it.
The exam taxonomy reads the
longcomponent oflong doubleas a size specifier applied to the base typedouble, and files it under its broad qualifier heading — not as a member-declaring type like a union, not as a type constructed from another type like a pointer, and not as a language-supplied fundamental name like void. (Written on its ownlongis still a valid type specifier:long x;declares along int.)Each of 1, 2, 3 and 4 is consumed exactly once, so the code has to be a rearrangement of all four numbers.
Result.
List – I entry | Matches |
|---|---|
a. User defined type | 2. Union |
b. Built-in type | 3. Void |
c. Derived type | 4. Pointer |
d. Long double | 1. Qualifier |
Read in the order a b c d, the code is 2 3 4 1.
Explore the full course: Mppsc Assistant Professor Computer Science Paper 2