What is the primary difference between malloc() and calloc() functions in C?
Answer: B
Both malloc() and calloc() allocate dynamic memory. The key difference is that malloc() allocates uninitialized memory (contains garbage values), while calloc() allocates memory and initializes all bytes to zero. calloc() also takes two arguments (number of elements and size of each element), while malloc() takes one (total bytes needed).
Q.202Medium
If arr[5] = {1, 2, 3, 4, 5}, what will be the value of *(arr + 3)?
Answer: B
In array notation, arr is a pointer to the first element. *(arr + 3) dereferences the pointer that points to the 4th element (index 3). Since array indexing is 0-based: arr[0]=1, arr[1]=2, arr[2]=3, arr[3]=4. Therefore, *(arr + 3) = 4.
Q.203Easy
Which header file must be included to use the printf() function in C?
Answer: B
The printf() function is defined in the Standard Input/Output library. Therefore, '#include <stdio.h>' must be included at the beginning of the program to use printf() and other I/O functions like scanf(), getchar(), putchar(), etc.
Q.204Medium
Consider a structure: struct Point { int x; int y; }; If p is a pointer to this structure and we want to access member x, which notation is INCORRECT?
Answer: C
When p is a pointer to a structure, we cannot use p.x (dot notation) directly. The correct ways are: p->x (arrow operator) or (*p).x (dereference then dot operator). The notation p.x would be used only if p were a structure variable, not a pointer. Therefore, p.x is incorrect when p is a pointer.
Q.205Easy
Which normal form eliminates transitive dependencies in a database table?
Answer: A
3NF removes transitive dependencies where a non-key attribute depends on another non-key attribute. BCNF is stricter but 3NF is the standard answer for eliminating transitive dependencies.
Advertisement
Q.206Easy
What is the time complexity of a binary search algorithm on a sorted array?
Answer: B
Binary search divides the search space in half with each iteration, resulting in logarithmic time complexity O(log n).
Q.207Easy
Which SQL command is used to remove a table structure along with its data?
Answer: B
DROP removes the entire table structure and data. DELETE removes only data. TRUNCATE removes data but is faster than DELETE.
Q.208Easy
In a hash table, what is the primary cause of collision?
Answer: A
Hash collisions occur when two different keys hash to the same table index. Resolution techniques include chaining and open addressing.
Q.209Easy
Which of the following is NOT a characteristic of a relational database?
Answer: C
Relational databases store structured data in tables. Unstructured data is typically stored in NoSQL or document databases.
Q.210Easy
What does the acronym ACID stand for in database transactions?
Indexes speed up data retrieval by creating optimized lookup structures, reducing the number of disk accesses needed to find data.
Q.215Medium
In cybersecurity, what does encryption primarily protect against?
Answer: C
Encryption converts data into unreadable format, protecting it from unauthorized access during transmission and storage.
Q.216Medium
Which sorting algorithm has the best average-case time complexity?
Answer: B
Merge Sort and Quick Sort have O(n log n) average complexity. Merge Sort guarantees this; Quick Sort can degrade to O(n²) in worst case.
Q.217Medium
What is the primary function of a query optimizer in a DBMS?
Answer: B
The query optimizer analyzes different execution strategies and selects the one with minimal resource consumption and execution time.
Q.218Medium
In machine learning basics, what is the purpose of training data in AI models?
Answer: B
Training data is used to teach AI models to recognize patterns. Test data evaluates accuracy; validation data prevents overfitting.
Q.219Hard
What is a deadlock in database management?
Answer: A
A deadlock occurs when two or more transactions wait for resources held by each other, creating a circular wait condition that prevents progress.
Q.220Hard
Which of the following best describes eventual consistency in distributed databases?
Answer: B
Eventual consistency is a model in NoSQL and distributed systems where updates propagate asynchronously, achieving consistency over time rather than immediately.