Multiple choice technology programming languages

import java.util.*; class GFC118 { public static void main (String[] args) { Object i = new ArrayList().listIterator(); System.out.print((i instanceof List)+","); System.out.print((i instanceof Iterator)+","); System.out.print(i instanceof ListIterator); }} What is the result of attempting to compile and run the program?

  1. Prints: false,false,false

  2. Prints: false,true,false

  3. Prints: false,true,true

  4. Prints: true,true,false

  5. Prints: true,true,true

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

ArrayList.listIterator() returns a ListIterator object. A ListIterator is NOT an instanceof List (it's an iterator over a list), but it IS an instanceof Iterator (implements that interface), and IS an instanceof ListIterator. Thus the output is 'false,true,true'. Option C matches this output.