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:
Verified
Q61: Which one of the following code snippets
Q69: Consider the following code snippet: ArrayList<Integer> num1
Q76: Which one of the following is a
Q79: Consider the following code snippet:
Int val =
Q81: What is the output of the following
Q83: What is the output of the code
Q90: Which one of the following statements about
Q97: Which statement is true about the code
Q100: Which one of the following is a
Q110: When an integer literal is added to
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents