- Home
- MCQs by exam
- PPSC IT
- Computer Science MCQs
PPSC IT MCQs – Computer Science MCQs · Page 5
346 multiple choice questions typical of the PPSC IT exam, with answers and explanations. Switch on practice mode to test yourself first.
-
A
They are discarded immediately, because w modes truncate a file that already exists
Correct answer
-
B
They are preserved until the first write, which then overwrites the file from its beginning
-
C
They are preserved and writes append at the end, because + implies append access
-
D
The open call fails with an error, since w+ is only valid for files that do not exist
-
A
a[0] is indeterminate and a[4] is 7, since only the named element is touched
-
B
a[0] is 7 and a[4] is 0, because the first initialiser fills the leading element
-
C
Both are 7, because one designated initialiser applies to the whole aggregate
-
D
a[0] is 0 and a[4] is 7, since omitted elements are initialised as if static
Correct answer
-
A
Because the function reports read errors by returning a negative byte count
-
B
So the out-of-band EOF value cannot be confused with any valid character code
Correct answer
-
C
Because a returned character may be a multi-byte sequence that is wider than 8 bits
-
D
Because plain char is unsigned on most targets, which would otherwise discard the sign
-
A
Its storage duration becomes automatic, so it is created afresh on each function call
-
B
Its initialisation is deferred until the variable is first used inside the unit
-
C
Its value is placed in read-only memory, so only the defining unit can modify it
-
D
Its linkage becomes internal, so other translation units cannot refer to it by name
Correct answer
-
A
long, because the value exceeds the range of both int and unsigned int on this target
-
B
Undefined, because no signed 32-bit type can represent that particular bit pattern
-
C
unsigned int, because hexadecimal literals take the first type in their list that fits
Correct answer
-
D
int, because hexadecimal constants are signed by default unless a u suffix is supplied
-
A
Register, because the literal is a constant expression folded at compile time
-
B
Automatic, matching the enclosing block, so the array dies when that block exits
Correct answer
-
C
Static, so the array outlives the enclosing block and can safely be returned to its caller
-
D
Dynamic, because the compiler reserves the array with an implicit malloc call at run time
-
A
Undefined behaviour, because the shift count is not less than the operand's width
Correct answer
-
B
Defined to yield zero, because every set bit is shifted out of the 32-bit range entirely
-
C
Implementation-defined, so the compiler documents whether it wraps the count
-
D
A constraint violation, so a strictly conforming compiler must reject the code
-
A
The extra parentheses force a temporary object, so the postfix increment is discarded
-
B
The preprocessor evaluates i++ once and then passes the resulting value twice
-
C
The argument is substituted twice, so i is incremented twice in one expression
Correct answer
-
D
The macro expands into a full statement, so it cannot legally appear inside an expression
-
A
Exactly one byte, chosen so the type is large enough for the largest enumerator value
-
B
Exactly sizeof(int), because every enumerator is guaranteed to have type int in C
-
C
Exactly sizeof(long), because enums are stored in the widest integer type
-
D
An implementation-defined choice among char, signed int and unsigned int types
Correct answer
-
A
Assignment performs a shallow copy, so the two structs end up sharing member storage
-
B
Padding bytes may hold indeterminate values, so a byte comparison can report differences
Correct answer
-
C
The member-wise copy converts floating values, so bit patterns can differ in the last unit
-
D
memcmp inspects only the first member of the struct, ignoring all the trailing members
-
A
Accesses become atomic between threads, so no torn reads or partial writes can ever occur
-
B
A hardware memory barrier is inserted around each access to order it against other threads
-
C
The object is placed in a memory section that hardware cannot write behind the program's back
-
D
Every access written in the abstract machine is performed, so the compiler cannot cache it
Correct answer
-
A
int (*fp)(int); which means exactly the same thing as int *fp(int) under the C declarator precedence rules
-
B
int fp(*)(int); which places the pointer inside the parameter list rather than on the name
-
C
int (*fp)(int); which declares a function pointer, unlike int *fp(int) which declares a function
Correct answer
-
D
int *fp(int); which declares a function pointer, while int (*fp)(int) declares a function
-
A
4 and 3, because sizeof counts the terminating NUL while strlen does not
Correct answer
-
B
3 and 3, because both operators measure only the visible characters
-
C
3 and 4, because sizeof excludes the NUL that strlen includes in its count
-
D
4 and 4, because strlen also counts the implicit terminating NUL byte
-
A
memmove handles overlap by choosing a safe copy direction, while memcpy does not
Correct answer
-
B
memcpy refuses overlapping ranges at run time and returns a null pointer instead
-
C
memmove is needed only when the two ranges are exactly equal, not when they overlap
-
D
memcpy copies through a hidden temporary buffer, so it needs twice the stack space
-
A
fgets rewinds the file when it reaches the last record, so the final line is read again
-
B
feof returns true at the start of the last line, so the guard terminates far too early
-
C
puts flushes the buffer twice when the final newline is missing from the file
-
D
feof only becomes true after a read hits end of file, so one extra iteration runs
Correct answer
-
A
Only the characters before the newline, since the newline stays in the input stream
-
B
The line including its trailing newline character, if one was present in the input
Correct answer
-
C
The line with the newline stripped away, because fgets always truncates at the line terminator
-
D
The line with the newline replaced by a NUL plus the previous buffer contents kept
-
A
The copy is truncated to three bytes and a NUL fills the last position of dst
-
B
The call is rejected at run time and dst keeps its previous uninitialised bytes
-
C
The four bytes are copied with no terminating NUL, so dst is not a valid string
Correct answer
-
D
Three bytes are copied and a NUL is appended, since space is always reserved
-
A
They keep their latest modified values because the stack frame is never touched
-
B
They are reset to zero, since longjmp reinitialises the function's automatic objects
-
C
Their values are indeterminate if they were modified between setjmp and longjmp
Correct answer
-
D
Their values are reliably restored to the values they held at the setjmp call
-
A
uint8_t with value 44, because the sum wraps at 256 and is truncated back down
-
B
unsigned int with value 300, because uint8_t promotes to unsigned int on all targets
-
C
int with value 44, because the sum is computed in 8 bits and then sign-extended up
-
D
int with value 300, because both operands are promoted to int before the addition
Correct answer
-
A
2, because the remainder operator always normalises the result to a non-negative value
-
B
-2, because the quotient is floored downward, which shifts the remainder in the negative direction
-
C
1, because the sign of a remainder is taken from the divisor rather than from the dividend
-
D
-1, because division truncates toward zero, so the remainder keeps the dividend's sign
Correct answer
-
A
A container includes a hypervisor of its own, while a VM does not, so a container needs more privileged hardware
-
B
Containers cannot be networked, unlike virtual machines, which each receive their own network stack
-
C
A VM shares the host kernel while a container virtualises the hardware, which is why a VM starts faster
-
D
Containers share the host kernel and isolate at the process level, whereas each VM runs its own guest kernel
Correct answer
-
A
The instance is immediately terminated and replaced
-
B
The instance is live-migrated to a host with spare capacity
-
C
It continues at full speed and is billed at the on-demand rate
-
D
Performance is throttled to the baseline until credits accumulate again
Correct answer
-
A
Resources are created only in the first apply of each day, and later runs are silently skipped
-
B
The tool rolls back every change made by a failed run, restoring the previous state automatically and safely
-
C
Applying the same template repeatedly converges to the same state instead of creating duplicate resources
Correct answer
-
D
Each apply must be run exactly once, since repeated runs change resource identifiers every time
-
A
Cache-Control with max-age, and s-maxage which overrides it for shared caches
Correct answer
-
B
Content-Length, which sets the freshness window in seconds for the response
-
C
ETag, which fixes the cache lifetime and forces revalidation on every single request
-
D
Vary, which sets a separate cache lifetime per client and per user agent string
-
A
A single-instance production database with no replica and a strict uptime requirement
-
B
A licensing server that must stay online during business hours and cannot tolerate a restart
-
C
A stateful session store for a shopping cart that must survive an abrupt termination
-
D
A checkpointed batch rendering job that can resume after a two-minute interruption notice
Correct answer