Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(TCOs 1, 4, and 6) _____ is used to display a series of items from which the use

ID: 3805119 • Letter: #

Question

(TCOs 1, 4, and 6) _____ is used to display a series of items from which the user may select one or more items. (Points : 3)

JLabel

JList

JTextArea

JArray

Question 2.2. (TCOs 1, 4, and 6) If you have a class called Student, which statement declares a JList that can hold Student objects called lstStudents? (Points : 3)

JList lstStudents<Student>;

JList <Student> lstStudents;

JList lstStudents(Student);

JList lstStudent.Student();

Question 3.3. (TCOs 1, 4, and 6) Which method will decrease the number of elements in an ArrayLlist? (Points : 3)

delete

remove

get

purge

Question 4.4. (TCOs 1, 4, and 6) Which method will remove all elements in an ArrayList employees? (Points : 3)

employees.delete()

employees.clear()

employees.empty()

employees.remove()

Question 5.5. (TCOs 1, 4, and 6) Which method of a JList returns -1 if no item in the list is selected? (Points : 3)

getSelectedIndex

getSelectedValue

getIndex

getValue

Question 6.6. (TCOs 1, 4, and 6) The method used to add panels to a JTabbedPane is (Points : 3)

newTab.

newPanel.

addPanel.

addTab.

Question 7.7. (TCOs 1, 4, and 6) A tool tip can be specified for a tab using the _____ method. (Points : 3)

Tooltip

addTab

setTooltip

tabTip

Question 8.8. (TCOs 1, 4, and 6) Suppose ArrayList cities contain the two strings {“Chicago”, “Miami”}. Which of the following methods will cause the list to become {“Houston”,“Chicago”,“Miami”}? (Points : 3)

cities.add(“Houston”)

cities.add(0, “Houston”)

cities.add(1, “Houston”)

cities.add(2, “Houston”)

Question 9.9. (TCOs 1, 4, and 6) Which of the following is false regarding overriding of the toString method? (Points : 3)

toString method must have no parameters.

toString method must have parameters.

The string representation of the object is determined by the programmer.

toString method must return a String.

Question 10.10. (TCOs 1, 4, and 6) Assume you have created a JTabbedPane object called myTabs. You also have a JPanel object called myPanel. Which statement adds this panel to the tabbed pane with a title of “Add”? (Points : 3)

myTabs.newTab(myPanel, “Add”);

myPanel.addToTab(myTabs, “Add”);

myTabs.addTab(myPanel, “Add”);

myTabs.addTab(“Add”, myPanel);

Explanation / Answer

Question 1.1

Answer: JList

Question 2.2

Answer: JList <Student> lstStudents;

Question 3.3

Answer: remove

Question 4.4

Answer: employees.clear()

Question 5.5

Answer: getSelectedIndex

Question 6.6

Answer: addTab

Question 7.7

Answer: setTooltip

Question 8.8

Answer: cities.add(0, “Houston”)

Question 9.9

Answer: toString method must have parameters.

Question 10.10

Answer: myTabs.addTab(“Add”, myPanel);