What will be the output of: int x = 5; int y = x++ + ++x; ?
Answer: D
This expression involves modifying the same variable (x) multiple times without an intervening sequence point. This is undefined behavior in C, and the result cannot be predicted reliably.
Q.42Hard
What is the output of this recursive function?
int func(int n) {
if(n <= 1) return 1;
return n * func(n-1);
}
printf("%d", func(4));
What is the output of this code involving bitwise operations?
int x = 5; // binary: 0101
int y = 3; // binary: 0011
printf("%d", x ^ y); // XOR operation
Answer: A
XOR operation: 5 ^ 3. Binary: 0101 ^ 0011 = 0110 = 6. XOR returns 1 when bits are different, 0 when same.
Q.44Hard
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.45Hard
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.
Advertisement
Q.46Hard
In network protocols, which layer does TCP/IP operate at?
Answer: C
TCP operates at Layer 4 (Transport) and IP at Layer 3 (Network) in the OSI model. Together they form the TCP/IP protocol suite.
Q.47Hard
What is the primary vulnerability addressed by SQL injection prevention techniques like parameterized queries?
Answer: B
Parameterized queries prevent SQL injection by separating query structure from data, ensuring user input cannot be interpreted as executable code.
Q.48Hard
In the context of graph databases, what is the primary advantage over relational databases for relationship-heavy queries?
Answer: B
Graph databases excel at querying relationships with O(1) traversal time, whereas relational databases require expensive JOIN operations for similar queries.
Q.49Hard
What does CAP theorem state in distributed systems?
Answer: A
CAP theorem (Brewer's theorem) states distributed systems must choose 2 of 3 properties: strong consistency (C), continuous availability (A), or tolerance to network partitions (P).
Q.50Hard
In cybersecurity, what is a zero-day vulnerability?
Answer: A
Zero-day vulnerabilities are previously unknown exploits with no patch. They're extremely dangerous because users have no defense until vendors develop and release fixes.
Q.51Hard
What does BASE model in NoSQL stand for?
Answer: A
BASE is an alternative to ACID, prioritizing availability and partition tolerance. It accepts temporary inconsistencies that resolve eventually (eventual consistency).
Q.52Hard
In database replication, what is the primary difference between synchronous and asynchronous replication?
Answer: C
Synchronous replication waits for replicas to acknowledge writes (safer but slower), while asynchronous replication doesn't wait (faster but less safe).
Q.53Hard
Which of the following best describes a distributed transaction and its challenges in microservices architecture?
Answer: B
Distributed transactions in microservices require mechanisms like Saga pattern or Two-Phase Commit to maintain consistency across services.
Q.54Hard
In cybersecurity, what is SQL injection and why is it a critical vulnerability in 2024?
Answer: A
SQL injection allows attackers to insert malicious SQL code through application inputs, remaining a critical OWASP Top 10 vulnerability despite awareness.
Q.55Hard
What is the primary advantage of using GraphQL over traditional REST APIs in modern application architecture?
Answer: B
GraphQL's query language enables clients to specify exact data requirements, eliminating over-fetching and under-fetching issues common in REST.
Q.56Hard
In a B-tree of order m, what is the maximum number of keys that a non-root node can contain?
Answer: C
A B-tree of order m can have at most 2m-1 keys in any node and minimum m-1 keys in non-root nodes.
Q.57Hard
In database normalization, what does the Boyce-Codd Normal Form (BCNF) address that 3NF might miss?
Answer: B
BCNF handles edge cases in 3NF where anomalies can occur with composite candidate keys where determinants are not candidate keys themselves.
Q.58Hard
In distributed systems, what is a consensus algorithm primarily used for?
Answer: B
Consensus algorithms (like Raft, Paxos) enable distributed systems to reliably agree on state even with node failures.
Q.59Hard
What is the primary challenge of implementing ACID properties in distributed databases?
Answer: B
The CAP theorem shows it's impossible to guarantee all three: Consistency, Availability, and Partition tolerance simultaneously.
Q.60Hard
In AI/ML, what is the role of activation functions in neural networks?