🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Unique ID Generator: all 15 questions

Quiz: Unique ID Generator · Question 3 of 15

What does this print? (code)

What does this print?

ts, machine, seq = 5, 3, 2
i = (ts << 22) | (machine << 12) | seq
print(i >> 22, (i >> 12) & 1023, i & 4095)
  1. A.5 3 0
  2. B.5 3 2
  3. C.2 3 5
  4. D.20971520 3 2
Answer & explanation

Correct answer: 5 3 2

Shifting right and masking pulls each field back out exactly as it went in.

Can you get the rest right without peeking?

Take the timed Quiz: Unique ID Generator quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →