Solved

What Is the Output of the Following Code Snippet

Question 46

Multiple Choice

What is the output of the following code snippet?
Public static int check(ArrayList<Integer> listData)
{
Int sum = 0;
For (int i = 0; i < listData.size() ; i++)
{
Sum = sum + listData.get(i) ;
}
Return sum;
}
Public static void main(String[] args)
{
ArrayList<Integer> vdata = new ArrayList<Integer>() ;
Int rsum;
For (int cnt = 0; cnt < 3; cnt++)
{
Vdata.add(cnt + 1) ;
}
Rsum = check(vdata) ;
System.out.println(rsum) ;
}


A) 4
B) 2
C) 3
D) 6

Correct Answer:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions