Data innextint num1adddata if num1i 2 0

This preview shows page 3 - 5 out of 18 pages.

{data = in.nextInt();num1.add(data);if (num1[i] % 2 != 0){oddnum.add(num1[i]);}}Answer: B5) Consider the following code snippet:ArrayList<Integer> num1 = new ArrayList<Integer>();int data;Scanner in = new Scanner(System.in);for (int i = 0; i < 5; i++){data = in.nextInt();num1.add(data);if (data == 0 && num1.size() > 3){num1.remove(num1.size() - 1);}}System.out.println("size is : " + num1.size());What is the output of the given code snippet if the user enters 1,2,0,0,1 as the input?a) size is : 1b) size is : 2c) size is : 4d) size is : 0Answer: C
6) Which one of the following is a correct declaration for a method namedpassAListwith the array listnumof size 5 as aparameter?
7) Consider the following line of code for calling a method namedfunc1func1(listData, varData);Which one of the following method headers is valid forfunc1,wherelistDatais an integer array list andvarDatais an integervariable?:
3
4

Upload your study docs or become a

Course Hero member to access this document

Upload your study docs or become a

Course Hero member to access this document

End of preview. Want to read all 18 pages?

Upload your study docs or become a

Course Hero member to access this document

Term
Fall
Professor
Montague
Tags
English language films, Syntax highlighting, Run time, Compile time

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture