1. Home
  2. Subjects
  3. Computer Science MCQs

Computer Science MCQs · Page 3

992 multiple choice questions with answers across 24 topics.

Showing 51–75 of 992

p points to the third element of a block obtained from malloc. What happens if the program calls free(p)?

  1. Undefined behaviour, because free needs the pointer that malloc returned Correct answer
  2. Only the memory beyond p is released, and the earlier part stays allocated
  3. The call is legal and releases the whole block through the allocation header
  4. A diagnostic is guaranteed, since free can detect an interior pointer
MCQSEXAM Read explanation

Three handlers are registered with atexit in the order h1, h2, h3, and then main returns normally. In what order do the handlers run?

  1. Only the last registered handler h3 runs when main returns normally
  2. h3, then h2, then h1, since handlers run in reverse registration order Correct answer
  3. h1, then h2, then h3, since handlers run in registration order exactly
  4. The order is unspecified, so any permutation of the three is conforming
MCQSEXAM Read explanation

Two records compare equal under a qsort comparator. What does the C standard guarantee about their relative order after sorting?

  1. They keep their original relative order, since qsort is a stable sort
  2. Their order is reversed, because qsort always swaps equal elements
  3. Their order stays unspecified unless the comparator breaks the tie itself
  4. Nothing is guaranteed, because qsort is not required to be stable at all Correct answer
MCQSEXAM Read explanation

A goto statement jumps forward over the declaration int a[n]; inside the same block. Why does a conforming C compiler reject this?

  1. Because goto may not cross any declaration that has an initialiser
  2. It is rejected only when n is a compile-time constant expression
  3. Jumping into the scope of a variably modified object is not permitted Correct answer
  4. The jump is legal, but the array a stays uninitialised until it is used
MCQSEXAM Read explanation

Given typedef int *intptr; the declaration intptr a, b; differs from a #define of intptr for int * in which respect?

  1. The typedef makes both a and b pointers; the macro makes only a pointer Correct answer
  2. Both forms declare two pointers, since the tokens are expanded identically
  3. The typedef makes both ints, while the macro makes a pointer and an int
  4. The macro form is a constraint violation and does not compile in C
MCQSEXAM Read explanation

A program shifts a negative int value both left (x << 1) and right (x >> 1). Under the C standard, how are the two operations classified?

  1. Both shifts on negative values are undefined behaviour in standard C
  2. Both shifts are well defined and act on the two's complement bit pattern
  3. Left shift of a negative is implementation-defined, but right shift is undefined
  4. Left shift of a negative is undefined; right shift is implementation-defined Correct answer
MCQSEXAM Read explanation

Both f() and g() are passed to printf as arguments and each increments the same global counter. What does standard C guarantee about the values printed?

  1. g() always runs first, because the arguments are evaluated right to left
  2. Nothing; the calls are indeterminately sequenced, so either order can occur Correct answer
  3. f() always runs first, since it appears leftmost in the argument list
  4. The program has undefined behaviour, because one global object is written twice
MCQSEXAM Read explanation

A workload streams 10 TB a month out to the internet while ingesting the same volume. Which cost dominates, and why?

  1. Egress dominates, because data transferred out to the internet is billed and inbound is free Correct answer
  2. Ingress dominates, because inbound data is billed per gigabyte while outbound egress is free of charge
  3. They cost the same, because both directions are billed at the identical per-gigabyte rate today
  4. Neither is billed, because traffic remains free while it stays within a single AWS region
MCQSEXAM Read explanation

A bucket replicates to another region with S3 Cross-Region Replication. What recovery point objective does the replica give?

  1. The bucket's versioning window, because the replica retains every prior object version written
  2. Near-zero but not zero, because replication is asynchronous and may lag by seconds or minutes Correct answer
  3. Exactly zero, because replication is synchronous and commits the object to both regions together
  4. Zero for new objects only, since existing objects are copied synchronously when it is enabled
MCQSEXAM Read explanation

A table is written with 10 items per second, each item 6 KB in size. How many write capacity units are needed?

  1. 10, because DynamoDB charges one write unit per item regardless of the individual item size
  2. 30, because each item rounds up to three units and the remaining size is ignored here
  3. 120, because writes are billed twice over when the table uses eventual consistency
  4. 60, because each 6 KB item consumes six write units and ten are written per second Correct answer
MCQSEXAM Read explanation

A VPC subnet is created with CIDR 10.0.4.0/24 in AWS. How many IP addresses can actually be assigned to resources?

  1. 254, because only the network and broadcast addresses are unusable inside a subnet here
  2. 250, because AWS reserves six addresses once the VPC router is also counted
  3. 251, because AWS reserves five addresses in every subnet for networking functions Correct answer
  4. 256, because a /24 mask leaves eight host bits with no addresses reserved
MCQSEXAM Read explanation

In KMS envelope encryption, what is the role of the data key?

  1. It replaces the customer master key for all requests, sharply reducing KMS API call volume
  2. It is a plaintext credential that must be rotated manually with every object written
  3. It encrypts the data locally, and is itself stored encrypted under a KMS customer key Correct answer
  4. It encrypts the customer master key, so the master key never leaves the KMS service
MCQSEXAM Read explanation

A static site on CloudFront must serve a corrected file immediately everywhere. Which approach avoids stale edge copies most reliably?

  1. Issue an invalidation for /* first, then upload the fixed file to the same key
  2. Set the origin's Cache-Control max-age to zero, which flushes all existing edge copies at once
  3. Reduce the default TTL to 60 seconds, which bounds how long an edge copy is stale
  4. Version the object key, such as app-v2.js, so the CDN path itself is new and uncached Correct answer
MCQSEXAM Read explanation

What does setting reserved concurrency on a Lambda function actually do?

  1. It raises the function's default timeout to match the reserved concurrency value in seconds
  2. It provisions dedicated EC2 capacity that is billed whether or not it is invoked
  3. It carves out and caps concurrency for that function, throttling it beyond the limit Correct answer
  4. It guarantees the function never cold-starts, by keeping the reserved pool warm
MCQSEXAM Read explanation

A consumer receives an SQS message, then its visibility timeout expires before it is deleted. What happens next?

  1. The message stays invisible until the queue's retention period eventually expires
  2. The message becomes visible again and another consumer may process it a second time Correct answer
  3. The message is permanently deleted, because the expired timeout counts as an acknowledgement
  4. The message moves to the dead-letter queue immediately, since the receive has failed
MCQSEXAM Read explanation

An object archived to S3 Glacier Flexible Retrieval must be readable within minutes. Which retrieval tier applies and how is it priced?

  1. Instant, which is the only tier available to Glacier Flexible Retrieval archive objects
  2. Expedited, which typically returns data in 1-5 minutes and is the most expensive tier Correct answer
  3. Bulk, which returns data within 5-12 hours and is the cheapest of the available tiers
  4. Standard, which returns data in 3-5 hours and costs the same as expedited retrieval
MCQSEXAM Read explanation

How does an RDS Multi-AZ standby differ from a read replica in normal operation?

  1. Both are synchronous copies, but only the standby can serve read queries under load
  2. Both are asynchronous copies, and either can be promoted to primary without any data loss at all
  3. The standby is synchronous and not readable, while a replica is asynchronous and queryable Correct answer
  4. The standby is asynchronous and readable, while a replica is synchronous and write-only
MCQSEXAM Read explanation

An EBS gp3 volume is created with default settings. What baseline performance does it provide regardless of volume size?

  1. 16000 IOPS and 1000 MiB/s, the maximum that any gp3 volume can ever reach
  2. 3000 IOPS and 125 MiB/s, with extra IOPS and throughput purchased separately Correct answer
  3. 3000 IOPS and 250 MiB/s, with throughput scaling automatically with volume size
  4. 100 IOPS per GiB and 250 MiB/s, both scaling in proportion to the volume's size
MCQSEXAM Read explanation

Which statement correctly distinguishes instance store from EBS-backed volumes on EC2?

  1. Instance store is ephemeral local disk tied to the host, while EBS persists independently Correct answer
  2. Instance store survives a stopped instance, while EBS volumes are deleted with the host
  3. Both are network-attached, but instance store offers higher durability by replicating twice
  4. Instance store is billed per gigabyte-month, while EBS is included in the instance price
MCQSEXAM Read explanation

What does the cooldown period of an Auto Scaling group actually prevent?

  1. New instances from receiving traffic until their health checks have passed twice in a row
  2. Scale-in events entirely, so the group can only ever grow during a traffic spike
  3. The load balancer from deregistering instances that are still serving requests
  4. Further scaling actions until metrics stabilise, avoiding repeated over-correction Correct answer
MCQSEXAM Read explanation