4. Read Java code (of CarFrame program), answer following questions: About Array
ID: 3694422 • Letter: 4
Question
4. Read Java code (of CarFrame program), answer following questions: About Array a) Where a field of an array is initialized? What type of array is it? What is its size? b) Where the array you found in d) is used? Find some of its usages. c) In the constructor, there is a for loop. How many times does it execute? Which variable is the index? About ArrayList d) Where an ArrayList is initialized? What type of list is that? e) Where the list object you found in a) is used? Find ALL its usages f) Which methods are called on the list object you found in a)? [There are three different method calls on it.]Explanation / Answer
Please follow the below data :
About Arrays :
1) In the line 13 an array is initialized of JLabel type and size of 4. It is used to store the piclabels as stated.
2) The found array is used in the line 35 and it is used to add the cards to the deck using a loop.
3) In the constructer's for-loop, it executes 4 times (starting from 0 to 3) with the variable "i" as the index.
About ArrayLists :
1) In the line 8 an arraylist is initialized of type integer with a variable as Card.
2) The object picLabel is used in two different parts of the program for different uses.
a) First it is used in the line 27 .Here it is used to add the labels to the main panel for grid layout type.
b) Second it is used in line 50. Here it is used to remove the icons sequentiallyby setting the icon to a a null value.
3) a) First it is used in the line 27 by creating a new JLabel so that the input labels can be added.
b) Secondly it is used in the line 50 to set the icon to a null value.
c) Thirdly it is used in the line 59 to set the label from the icon of the card.
Hope this is helpful.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.