Limited access

Upgrade to access all content for this subject

Consider the following method.

public static String alphaString(ArrayList<String> words)
{
    String s="";
    String vowels = "aAeEiIoOuU";
    for (int i=words.size()-1; i>=0; i--)
    {
        int v=0;
        for (int j=0; j<words.get(i).length(); j++)
        {
            if (vowels.indexOf(words.get(i).substring(j,j+1))>=0)
                v++;
        }
        s+=v;
    }
    return s;
}

What will the following code segment print?

ArrayList<String> words = new ArrayList<String>();
words.add("dragon");
words.add("snakes");
words.add("worm");
words.add("iguana");
words.add("copperhead");
words.add("toad");
System.out.println(alphaString(words));
A
36
B
244122
C
221442
D
15
E
null
Select an assignment template