What will be the result of the following code compilation and execution?

import java.util.*;
public class Test {
    public static void main(String[] args) {
        List buf = new ArrayList(2);

        System.out.print(buf.size());

        buf.add(10);

        System.out.print(buf.size());

        buf.add(20);
        buf.add(30);

        System.out.print(buf.size());
    }
}
Explanation
Get an explanation when it's available:

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Cosmo
Sign Up Now
or Subscribe for future quizzes