Strings MCQ Practice

Question 1 of 10

What is "net" + "work"?

  1. A. worknet
  2. B. net+work
  3. C. network
  4. D. net work

Question 2 of 10

Inclusive 1-based substring: what is substring("PYTHON", 2, 5)?

  1. A. YTHON
  2. B. PTHO
  3. C. THO
  4. D. YTHO

Question 3 of 10

substring(s, start, end) returns the characters from index start through index end, inclusive, with the first character at index 1. What is displayed?

x ← "AIR"
y ← "PLANE"
DISPLAY (x + substring(y, 1, 5))
  1. A. AIRPLANE
  2. B. AIRANE
  3. C. PLANEAIR
  4. D. AIRPLAN

Question 4 of 10

substring(s, start, end) returns the characters from index start through index end, inclusive, with the first character at index 1. A coder extracts a character with substring(full, 6, 6) from full ← "Ada M Lee". What character is returned?

Index 1 2 3 4 5 6 7 8 9
Char A d a M L e e
  1. A. M
  2. B. a space character
  3. C. L
  4. D. a

Question 5 of 10

Which expression produces "YES"?

  1. A. substring("YES", 1, 2)
  2. B. "YE" + ""
  3. C. "Y" + "E" + "S"
  4. D. "Y" + "ES "

Question 6 of 10

Trace with inclusive substring.

w ← "BOARD"
DISPLAY (substring(w, 1, 1) + substring(w, 4, 5))
  1. A. BAD
  2. B. BD
  3. C. BOAR
  4. D. BRD

Question 7 of 10

For text ← "QUIZ", which call returns "UI"?

  1. A. substring(text, 2, 3)
  2. B. substring(text, 2, 4)
  3. C. substring(text, 3, 3)
  4. D. substring(text, 1, 2)

Question 8 of 10

substring(s, start, end) returns the characters from index start through index end, inclusive, with the first character at index 1. What is "A" + "B" + "C" + substring("DEF", 1, 1)?

  1. A. DEF
  2. B. ABCD
  3. C. ABC D
  4. D. ABC

Question 9 of 10

If first ← "data" and second ← "base", what is first + second?

  1. A. basedata
  2. B. data+base
  3. C. database
  4. D. data base

Question 10 of 10

A form builds initials. Given name ← "Kai" and using inclusive substring, which expression yields "K" + "i"?

  1. A. substring(name, 1, 2)
  2. B. substring(name, 2, 3)
  3. C. substring(name, 1, 1) + substring(name, 2, 2)
  4. D. substring(name, 1, 1) + substring(name, 3, 3)