1. Home
  2. MCQs by exam
  3. NTS

NTS MCQs · Page 65

5,604 multiple choice questions typical of the NTS exam, with answers and explanations. Switch on practice mode to test yourself first.

Showing 1601–1625 of 5,604

char buf[8]; int n = snprintf(buf, sizeof buf, "%s", "abcdefghij"); What are n and the contents of buf?

  1. n equals 10, but buf is left holding all ten characters without a terminator
  2. n equals -1, because the output was truncated by the size argument given
  3. n equals 10, and buf holds the first seven characters plus a terminator Correct answer
  4. n equals 7, and buf holds exactly the seven characters that it kept
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

An ideal gas is compressed from 100 kPa to 400 kPa at constant temperature, with R equal to 0.287 kJ/kg K. What is the specific entropy change?

  1. About +0.40 kJ/kg K, since compression raises the pressure of the gas
  2. About -0.40 kJ/kg K, from R times the logarithm of the pressure ratio Correct answer
  3. About -0.20 kJ/kg K, from R times the logarithm of the pressure ratio
  4. Zero, because an isothermal process for an ideal gas changes no entropy
MCQSEXAM Read explanation

Two large parallel plates exchange radiation. One thin shield with the same emissivity is placed between them. What happens to the net heat transfer?

  1. It stays unchanged, since the shield has the same emissivity as both
  2. It falls to about one third, because the view factor is reduced threefold
  3. It falls to about one half, because the shield adds an equal resistance Correct answer
  4. It falls to about one quarter, because two surfaces now face each other
MCQSEXAM Read explanation

A pipe is wrapped in insulation of conductivity k and exposed to surroundings with heat transfer coefficient h. What is the critical radius of insulation?

  1. k divided by h, and beyond that radius adding insulation cuts heat loss Correct answer
  2. h divided by k, and beyond that radius adding insulation cuts heat loss
  3. k divided by h, and beyond that radius adding insulation raises heat loss
  4. twice k divided by h, where the insulation matches the pipe radius
MCQSEXAM Read explanation

A clay layer reaches 50 percent consolidation in 1 year, with Tv50 = 0.197 and Tv90 = 0.848. About how long does 90 percent consolidation take?

  1. About 4.3 years, because time scales with the time factor for the layer Correct answer
  2. About 1.8 years, because time scales with the square root of that factor
  3. About 9.0 years, because time scales with the square of the time factor
  4. About 2.0 years, because the drainage path doubles between those degrees
MCQSEXAM Read explanation