Menu
Question Index
...

What will be the output of the following program?

import java.lang.reflect.*;
import java.util.*;

public class Reflector {
    public static void main(String[] args) throws Exception {
        Set<String> s = new HashSet<String>();
        s.add("B");
        s.add("A");
        s.add("B");
        s.add("A");
        Iterator it = s.iterator();
        Method m = it.getClass().getMethod("hasNext");
        System.out.println(m.invoke(it));
    }
}


B
BA
BABA
Some other output
Compilation Error or Runtime Error

Doubts

Problems

Topic: Collection Framework In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App