What can we see in the console after next code executes:

import java.util.ArrayList;
import java.util.Iterator;

public class Quizful {

    protected static ArrayList<Integer> wallet;
    
    public Quizful() {
        wallet = new ArrayList<Integer>();
    }    
    
    public static int money() {
        int aSum = 0;
        Iterator<Integer> iterator = wallet.iterator();    // --1--
        while (iterator.hasNext()) 
            aSum += iterator.next();

        return aSum;
    }
    
    public static int money2() {
        int aSum = 0;
        
        for (Integer I : wallet)    // --2--
            aSum += I.intValue();
        
        return aSum;
    }
    
    public static void main(String[] args) 
    {
        wallet.add(new Integer(5));   // --3--
        
        System.out.println(money() + money2());
    }
}
Java
Java Quiz
Start Quiz

or Read more about Java Quiz

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback