Home Tests Campus Placement

Campus Placement

Campus placement MCQ questions — Aptitude, Verbal, Reasoning, Technical.

2,162 Q 4 Subjects Any Graduate
Take Mock Test
Difficulty: All Easy Medium Hard 2151–2160 of 2,162
Advertisement
Q.2151 Easy Computer Knowledge C Programming
What will be the size of the following array in bytes?
char arr[10];
A 10 bytes
B 20 bytes
C 40 bytes
D 5 bytes
Correct Answer:  A. 10 bytes
EXPLANATION

Each char occupies 1 byte in memory. An array of 10 chars will occupy 10 × 1 = 10 bytes.

Take Test
Q.2152 Easy Computer Knowledge C Programming
Which of the following is the correct syntax to declare a pointer in C?
A int *ptr;
B int& ptr;
C int ^ptr;
D int @ptr;
Correct Answer:  A. int *ptr;
EXPLANATION

In C, pointers are declared using the asterisk (*) symbol before the variable name. The syntax is 'datatype *pointer_name;'

Take Test
Q.2153 Easy Computer Knowledge C Programming
What is the output of the following C code?
int x = 5;
printf("%d", x++);
A 6
B 5
C Compilation error
D Undefined behavior
Correct Answer:  B. 5
EXPLANATION

The post-increment operator (x++) returns the current value of x before incrementing. So printf prints 5, and then x becomes 6.

Take Test
Q.2154 Medium Computer Knowledge
Which data structure is most suitable for implementing a priority queue where elements with higher priority need to be dequeued first?
A Array
B Linked List
C Min-Heap or Max-Heap
D Graph
Correct Answer:  C. Min-Heap or Max-Heap
EXPLANATION

A Heap (either Min-Heap or Max-Heap) is the optimal data structure for implementing priority queues with O(log n) insertion and deletion time complexity.

In a Max-Heap, the element with the highest priority is always at the root, enabling efficient extraction of the maximum element.

Arrays and Linked Lists would require O(n) time for priority-based operations, while Graphs are unsuitable for this purpose.

Heaps are fundamental in algorithms like Dijkstra's and Prim's for finding shortest paths.

Take Test
Q.2155 Hard Computer Knowledge
In a B-tree of order m, what is the maximum number of children a non-leaf node can have?
A m
B m - 1
C m + 1
D 2m
Correct Answer:  C. m + 1
EXPLANATION

A B-tree of order m has a maximum of m children per node, which means it can have a maximum of (m-1) keys.

Each node can have between ⌈m/2⌉ and m children (for non-leaf nodes), ensuring balance. B-trees are commonly used in database indexing and file systems because they minimize disk I/O operations through their multi-level structure and balanced properties.

Take Test
Advertisement
Q.2156 Medium Computer Knowledge
Which of the following operations has an average time complexity of O(1) in a Hash Table with good hash function and low collision rate?
A Insertion only
B Search only
C Both insertion and search
D Deletion only
Correct Answer:  C. Both insertion and search
EXPLANATION

Hash Tables achieve O(1) average-case time complexity for both insertion and search operations when using a well-designed hash function that minimizes collisions and maintains a good load factor.

Deletion also operates in O(1) average time.

However, in worst-case scenarios with poor hash functions or high collision rates, these operations can degrade to O(n).

The key to performance is maintaining low collision rates through techniques like chaining or open addressing.

Take Test
Q.2157 Easy Computer Knowledge
Which data structure uses the LIFO (Last In First Out) principle and is commonly used for function call management in programming languages?
A Queue
B Stack
C Heap
D Linked List
Correct Answer:  B. Stack
EXPLANATION

A Stack follows LIFO principle where the last element inserted is the first one to be removed.

It is fundamental in managing function calls through the call stack, undo/redo operations, and expression evaluation.

Queues use FIFO, Heaps are used for priority ordering, and Linked Lists maintain sequential but flexible storage.

Take Test
Q.2158 Hard Computer Knowledge
What is the purpose of the volatile keyword in C?
A To prevent a variable from being modified by the program
B To inform the compiler that a variable may change unexpectedly and should not be optimized out or cached in registers
C To allocate memory on the stack instead of the heap
D To make a variable accessible across all files in a project
Correct Answer:  B. To inform the compiler that a variable may change unexpectedly and should not be optimized out or cached in registers
EXPLANATION

The volatile keyword tells the compiler that a variable's value may change at any time (due to external factors like hardware registers, signal handlers, or multi-threading) and should be read from memory every time it's accessed, rather than being optimized by the compiler or cached in a register.

Take Test
Q.2159 Hard Computer Knowledge
Consider a structure with bit fields. What will be the size of the following structure in bytes?

struct demo {
unsigned int a : 5;
unsigned int b : 3;
unsigned int c : 4;
unsigned int d : 7;
};
A 1 byte
B 2 bytes
C 4 bytes
D 8 bytes
Correct Answer:  C. 4 bytes
EXPLANATION

Bit fields in C are packed into the smallest integral type that can accommodate them.

Here, a(5) + b(3) + c(4) + d(7) = 19 bits total.

Since 19 bits exceed 16 bits but fit within 32 bits, the compiler allocates 4 bytes (32 bits) for this structure, following standard packing rules.

Take Test
Q.2160 Medium Computer Knowledge
What is the output of the following code snippet?

int main() {
char arr[] = "GATE";
char *p = arr;
printf("%d\n", sizeof(arr));
printf("%d", sizeof(p));
return 0;
}
A 4 and 4
B 5 and 4
C 5 and 8 (on 64-bit system)
D 4 and 8 (on 64-bit system)
Correct Answer:  C. 5 and 8 (on 64-bit system)
EXPLANATION

The output is 5 and 8 because sizeof(arr) returns 5 bytes (4 characters plus 1 null terminator in the string "GATE"), while sizeof(p) returns 8 bytes on a 64-bit system since p is a pointer variable and pointers occupy 8 bytes in 64-bit architecture. The key concept is that sizeof() behaves differently for arrays versus pointers: when applied to an array, it returns the total memory allocated for the entire array, but when applied to a pointer, it only returns the size of the pointer itself, not what it points to. Other options would be incorrect because they either miscalculate the array size by forgetting the null terminator, use incorrect pointer sizes (like 4 bytes for 32-bit systems), or confuse the size of the array with the size of the pointer variable.

Take Test
IGET
iget AI
Online · Ask anything about exams
Hi! 👋 I'm your iget AI assistant.

Ask me anything about exam prep, MCQ solutions, study tips, or strategies! 🎯
UPSC strategy SSC CGL syllabus Improve aptitude NEET Biology tips