1. Home
  2. MCQs by exam
  3. PPSC IT

PPSC IT MCQs · Page 3

577 multiple choice questions typical of the PPSC IT exam, with answers and explanations. Switch on practice mode to test yourself first.

Showing 51–75 of 577

What is the maximum execution timeout of a single AWS Lambda invocation?

  1. 15 minutes, after which the invocation is terminated by the service Correct answer
  2. 5 minutes, after which the invocation is terminated by the service
  3. 60 minutes, after which the invocation is terminated by the service
  4. 15 minutes, though only functions above 1 GB may use the full limit
MCQSEXAM Read explanation

A presigned S3 URL was generated using credentials from an IAM role that is deleted shortly afterwards. What happens when the URL is used before its expiry time?

  1. It works until expiry, since the signature alone authorises the request
  2. It works only for HEAD requests, because GET needs live credentials
  3. It fails only if the object's ETag changes after the URL was generated
  4. It fails, because the signing credentials must still be valid when used Correct answer
MCQSEXAM Read explanation

A user's identity policy allows s3:GetObject on a bucket, but the bucket policy contains an explicit Deny for that user. What is the result of the request?

  1. Denied only if the bucket policy also lists that user in a NotPrincipal element
  2. Allowed, because both statements are evaluated and the allow matches first
  3. Denied, because an explicit deny anywhere in IAM always overrides any allow Correct answer
  4. Allowed, because identity policies take precedence over resource policies
MCQSEXAM Read explanation

typeid(*basePtr) is evaluated where Base has no virtual functions and the object is really a Derived. What type is reported?

  1. The static type Base, because typeid ignores the dynamic type here Correct answer
  2. The dynamic type Derived, since typeid always inspects the vtable
  3. A std::bad_typeid exception, since the base class is not polymorphic
  4. The most-derived type, but only after a dynamic_cast has been performed
MCQSEXAM Read explanation

Why does the copy-and-swap assignment operator provide the strong exception guarantee?

  1. Swapping uses move assignment, which the standard requires to be noexcept
  2. The old state is replaced only after the copy has been fully constructed Correct answer
  3. The copy constructor cannot throw once the source object has been locked
  4. It avoids allocating memory, so no allocation failure can occur at all
MCQSEXAM Read explanation

A shared_ptr is built as std::shared_ptr<int>(new int[10]). What happens when the last reference to it goes away?

  1. Plain delete is called on the array pointer, which is undefined behaviour Correct answer
  2. delete[] is chosen automatically because the pointer type is an array
  3. The control block detects the array and calls the array deleter for you
  4. Nothing is freed, because shared_ptr never deletes array allocations at all
MCQSEXAM Read explanation

Inside a function template, what happens to the branch of an if constexpr whose condition is false for a given instantiation?

  1. It is removed before parsing, so even syntax errors in it are ignored
  2. It is compiled and executed at run time only if its condition is true
  3. It is discarded and not instantiated, so dependent code there may be invalid Correct answer
  4. It is still instantiated and type-checked, then removed later as a dead branch
MCQSEXAM Read explanation

A class holds a std::unique_ptr<Impl> member and defines its destructor only in the header as = default. Why does this fail to compile?

  1. The defaulted destructor needs Impl complete to invoke the deleter on it Correct answer
  2. unique_ptr can never hold an incomplete type in any context in C++
  3. The constructor must see Impl to size the pointer, so the definition is needed
  4. The compiler cannot generate a move constructor for an incomplete member
MCQSEXAM Read explanation

What is the lifetime of the backing array of a std::initializer_list bound to a local variable?

  1. It has static storage duration, so returning the list by value is safe
  2. It ends with the full-expression that created it, like any temporary array Correct answer
  3. It ends only with the enclosing block, exactly as a local const array does
  4. It lasts as long as the initializer_list object that was copied from it
MCQSEXAM Read explanation

double d = 3.9; int x{d}; What does a conforming C++11 compiler do with this declaration?

  1. Compiles and sets x to 3, since braced init truncates like a cast does
  2. Compiles and sets x to 4, since braced init rounds to the nearest integer
  3. Compiles with a warning, since the value is implementation-defined here
  4. Rejects it, because narrowing conversions are ill-formed in braced init Correct answer
MCQSEXAM Read explanation

In template<class T> void f(T&& x), what is T deduced as when the function is called with an lvalue int?

  1. int&, because the forwarding reference collapses to an lvalue reference Correct answer
  2. int, because the reference in the parameter is stripped before deduction
  3. int&&, because the parameter is declared as an rvalue reference to T
  4. const int&, because lvalues are deduced as const in template deduction
MCQSEXAM Read explanation

std::lower_bound is called on a range that is not partitioned with respect to the searched value. What is the outcome?

  1. The first element equal to the value, found by a linear scan fallback
  2. A compilation error, since the predicate cannot be checked in advance
  3. Undefined behaviour, because the range must be partitioned for the search Correct answer
  4. Unspecified behaviour; the algorithm still returns some element of the range
MCQSEXAM Read explanation

In std::map, what happens to the other iterators when one element is erased through an iterator?

  1. All iterators are invalidated, because the tree rebalances its nodes
  2. Iterators to later elements are invalidated, while earlier ones stay valid
  3. Iterators become valid again after the next insert into the container
  4. Only the erased iterator is invalidated; every other iterator stays valid Correct answer
MCQSEXAM Read explanation