Presentation is loading. Please wait.

Presentation is loading. Please wait.

MCQ Which is the correct syntax for placing the string "boat" into an ArrayList name recVehicles in position 3 (index 2) for the first time? a)recVehicles.set(3,

Similar presentations


Presentation on theme: "MCQ Which is the correct syntax for placing the string "boat" into an ArrayList name recVehicles in position 3 (index 2) for the first time? a)recVehicles.set(3,"— Presentation transcript:

1 MCQ Which is the correct syntax for placing the string "boat" into an ArrayList name recVehicles in position 3 (index 2) for the first time? a)recVehicles.set(3, "boat"); b)recVehicles.add(2, "boat"); c)recVehicles.set("boat", 2); d)recVehicles.add("boat", 3); 1 Correct Answer = B Position 3 = index 2 public void add(int index,E element) public E set(int index, E element)

2 MCQ Which of the following statements correctly stores the value that is the 5th element in an ArrayList of integers, intArrList, into integer variable currNum? a)currNum = intArrList.get(5); b)currNum = intArrList[4]; c)currNum = intArrList.get(4); d)currNum = intArrList.elementAt(4); 2 Correct Answer = c 5 th element = index 4 get(int index)

3 MCQ Which of the following is used to obtain the size of a String (i.e. number of characters)? a) size() b) length c) length() d) capacity Correct Answer = C str.length() 3

4 MCQ Which of the following is used to obtain the size of an array? a) size() b) length c) length() d) capacity Correct Answer = B array.length 4

5 MCQ Which of these method of ArrayList class is used to obtain present size of an ArrayList object? a) size() b) length() c) index() d) capacity() 5 Correct Answer = A list.size()

6 JAVA API http://docs.oracle.com/javase/8/docs/api/ For example: String class Choose java.lang package, select String class ArrayList class Choose java.util package, select ArrayList class Point class Choose java.awt package, select Point class 6


Download ppt "MCQ Which is the correct syntax for placing the string "boat" into an ArrayList name recVehicles in position 3 (index 2) for the first time? a)recVehicles.set(3,"

Similar presentations


Ads by Google