Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134670942
Author: Y. Daniel Liang
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 11.11, Problem 11.11.2CP
Program Plan Intro
ArrayList:
A list of object is stored in the ArrayList. Once an array list is created, the size of the array is fixed. Java gives the ArrayList class for storing an unlimited number of objects in a single list.
Creation of ArrayList:
ArrayList <String> x = new ArrayList<String>();
The above statement is an example of creation of ArrayList. The array object “x” is used to store the list of objects.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
ion C Lons
Employee
-id: int
-name String
- dob : Date
-staff : ArrayList
+setid(int): void
+getld() : int
+setName(String): void
+setDob(Date) : void
+getDob(): Date
+addStaff(Employee) : void
+getStaff() : ArrayList
void listEmployees (void)
{
for (int i=0; i 10000.
Make a guess about why the comparison function takes 2 struct Employee
parameters (as opposed to struct Employee *)
**
Doctor
-signature:String
-doctorID:int
- medicine:Arraylist
+Doctor(signature:String,doctorID:int)
+PrescribeMedicine():void
+ salary ()
+checkRecords():void
Medicine
Pharmacist
-medName:String
-startTime:int
-dosage :int
-endTime:int
-date_prescribed:int
- medicine:Arraylist
+Medicine(medName:String,-dosage :int,date_prescribed:int)
+Pharmacist (startTime:int,endTime:int)
+checkForConflict():double
+confirm_prescription():String
+getStartTime():int
+getEndTime():int
+setStartTime(time:int):void
+setEndTime(time1:int).void
Chapter 11 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Ch. 11.2 - True or false? A subclass is subset of a...Ch. 11.2 - What keyword do you use to define a subclass?Ch. 11.2 - What is single inheritance? What is multiple...Ch. 11.3 - What is the output of running the class C in (a)?...Ch. 11.3 - How does a subclass invoke its superclasss...Ch. 11.3 - True or false? When invoking a constructor from a...Ch. 11.4 - True or false? You can override a private method...Ch. 11.4 - True or false? You can override a static method...Ch. 11.4 - How do you explicitly invoke a superclasss...Ch. 11.4 - How do you invoke an overridden superclass method...
Ch. 11.5 - Identify the problems in the following code:...Ch. 11.5 - Prob. 11.5.2CPCh. 11.5 - If a method in a subclass has the same signature...Ch. 11.5 - If a method in a subclass has the same signature...Ch. 11.5 - If a method in a subclass has the same name as a...Ch. 11.5 - Prob. 11.5.6CPCh. 11.7 - Prob. 11.7.1CPCh. 11.8 - Prob. 11.8.1CPCh. 11.8 - Prob. 11.8.2CPCh. 11.8 - Can you assign new int[50], new Integer [50], new...Ch. 11.8 - Prob. 11.8.4CPCh. 11.8 - Show the output of the following code:Ch. 11.8 - Show the output of following program: 1public...Ch. 11.8 - Show the output of following program: public class...Ch. 11.9 - Indicate true or false for the following...Ch. 11.9 - For the GeometricObject and Circle classes in...Ch. 11.9 - Suppose Fruit, Apple, Orange, GoldenDelicious, and...Ch. 11.9 - What is wrong in the following code? 1public class...Ch. 11.10 - Prob. 11.10.1CPCh. 11.11 - Prob. 11.11.1CPCh. 11.11 - Prob. 11.11.2CPCh. 11.11 - Prob. 11.11.3CPCh. 11.11 - Prob. 11.11.4CPCh. 11.11 - Prob. 11.11.5CPCh. 11.12 - Correct errors in the following statements: int[]...Ch. 11.12 - Correct errors in the following statements: int[]...Ch. 11.13 - Prob. 11.13.1CPCh. 11.14 - What modifier should you use on a class so a class...Ch. 11.14 - Prob. 11.14.2CPCh. 11.14 - In the following code, the classes A and B are in...Ch. 11.14 - In the following code, the classes A and B are in...Ch. 11.15 - Prob. 11.15.1CPCh. 11.15 - Indicate true or false for the following...Ch. 11 - Sections 11.211.4 11.1(The Triangle class) Design...Ch. 11 - (Subclasses of Account) In Programming Exercise...Ch. 11 - (Maximum element in ArrayList) Write the following...Ch. 11 - Prob. 11.5PECh. 11 - (Use ArrayList) Write a program that creates an...Ch. 11 - (Shuffle ArrayList) Write the following method...Ch. 11 - (New Account class) An Account class was specified...Ch. 11 - (Largest rows and columns) Write a program that...Ch. 11 - Prob. 11.10PECh. 11 - (Sort ArrayList) Write the following method that...Ch. 11 - (Sum ArrayList) Write the following method that...Ch. 11 - (Remove duplicates) Write a method that removes...Ch. 11 - (Combine two lists) Write a method that returns...Ch. 11 - (Area of a convex polygon) A polygon is convex if...Ch. 11 - Prob. 11.16PECh. 11 - (Algebra: perfect square) Write a program that...Ch. 11 - (ArrayList of Character) Write a method that...Ch. 11 - (Bin packing using first fit) The bin packing...
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Code NOT working. What to do? Here is code: appleList = [["Apple",52,14,0,0],["McIntosh red",80,18,0,0.5],["Gala (Apple)",52,11.4,0.2,0.3],["Fuji Apple",52,11.4,0.2,0.3],["Honey Crisp Apples",90,21,0,0],["Granny Smith Apples",52,11.4,0.2,0.3],["Red Delicious Apples",80,17,0,0],["Braeburn Apples",71.7,16,0.5,0.1],["Golden Delicious Apples",130,29,1,0],["Jonagold",130.7,34,1,0],["Cripps Pink Apple",80,18,0,0],["Empire Apples",80,17,0,0],["Produce Cortland Apples",70,6,1,5],["Jazz Apples",53.8,12,0.6,0.5],["Cameo Apples", 80,22,0,0]["Winesap Apples",80,22,0,0],["Rome Apples",80,22,0,0],["Ambrosia Apples",90,17,0.4,0],] print(":Type of Apple : Calories : Carbs (in GRAMS) : Protein (in GRAMS) : Fat (in GRAMS) :") for item in appleList:print(":",item[0]," "*(9-len(item[0])),":",item[1]," "*(13-len(item[1])),":",item[2]," "*(4-len(str(item[2]))),":")arrow_forwardFor any element in keysList with a value greater than 50, print the corresponding value in itemsList, followed by a comma (no spaces). Ex: If the input is: 32 105 101 35 10 20 30 40 the output is: 20,30, 1 #include 2 3 int main(void) { const int SIZE_LIST = 4; int keysList[SIZE_LIST]; int itemsList[SIZE_LIST]; int i; 4 6 7 8 scanf("%d", &keysList[0]); scanf ("%d", &keysList[1]); scanf("%d", &keysList[2]); scanf("%d", &keysList[3]); 10 11 12 13 scanf ("%d", &itemsList[0]); scanf ("%d", &itemsList[1]); scanf("%d", &itemsList[2]); scanf ("%d", &itemsList[3]); 14 15 16 17 18 19 /* Your code goes here */ 20 21 printf("\n"); 22 23 return 0; 24 }arrow_forwarddef fun_cities(adict, city): """ Question 7 - Given a dict that maps a fun activity to a list of cities where you could practice it, return the set of activities that one could practice at the provided city! - For an extra challenge, try doing this in one line (Optional). Args: adict (dict) city (str) Returns: set >>> activity_dict = {"Sightseeing": ["Venice", "Istanbul", "London"], "Kayaking": ["Venice", "Oslo", "Paris"], "Food Tasting": ["Paris", "Istanbul", "Mumbai"], "Going to the Theater": ["Paris", "Oslo", "London"]} >>> fun_cities(activity_dict, "Paris") {'Kayaking', 'Food Tasting', 'Going to the Theater'} >>> fun_cities(activity_dict, "Venice") {'Sightseeing', 'Kayaking'} # activity_dict = {"Sightseeing": ["Venice", "Istanbul", "London"], "Kayaking": ["Venice", "Oslo", "Paris"], # "Food Tasting": ["Paris", "Istanbul", "Mumbai"], "Going…arrow_forward
- * Question Completion Status: QUESTION 10 Analyze the following code and select the right print result SinglelinkedList testInstance = new SingleLinkedList(); testInstance.add("tom"); testInstance.add("dick"); testInstance.add("harry"); testInstance.add(2, "sam"); testInstance.remove(0); System.out.println(testInstance.toString()); O (tom ==> dick ==> sam ==> harry] O (dick ==> sam ==> hary] O (tom ==> dick ==> sam] O (tom ==> dick ==> hary] Click Save and Submit to save and submit. Click Save All Answers to save all answers. Save All Answers Close Wim exercice3.docx exercice2.docx TOSHIBA 近arrow_forwardNot allowed to add variables in brackets next to originIndex * @return index of the point that is closest to the origin, which is (0, 0) In * case of a tie, return the lowest index */ public int closestToOriginIndex() {arrow_forwardWhat criteria should be used to evaluate an ArrayList's performance?arrow_forward
- • Do not add statements that call print, input , or open , or add an import statement. • Do not use any break or continue statements. We are imposing this restriction (and we have not even taught you these statements) because they are very easy to abuse, resulting in terrible, hard to read code. • Do not modify or add to the import statements provided in the starter code. import math from typing import List, TextIO # For simplicity, we'll use "Station" in our type contracts to indicate that # we mean a list containing station data. # You can read "Station" in a type contract as: List[int, str, float, float, int, int, int] 23 # where the values at each index represent the station data as described in the # handout on Quercus. # A set of constants, each representing a list index for station information. ID - 0 NAME - 1 LATITUDE - 2 LONGITUDE - 3 CAPACITY - 4 BIKES_AVAILABLE - 5 DOCKS_AVAILABLE - 6 NO_KIOSK - 'SMART" # For use in the get_lat_lon_distance helper function EARTH RADIUS -…arrow_forwardvoid doo(list &L){ int item,a,p=L.size()-1; L.retrieve(p,a); for(int i=0;iarrow_forwardWhat is the running time for this code ?arrow_forwardFix an error and show it please?arrow_forwardThe below code declares a new Vector named 'vec'. What is the size of the vector at the end of the execution? Vector vec = new Vector(); for(int i=1;i<=10; i++) { vec.addElement(i); } vec.removeElement(9); vec.removeElement(10); vec.removeElement(11);arrow_forwardLooking for assistance with this question: Fulcrum def can_balance(items): Each element in items is a physical weight, a positive integer instead of some sort of helium balloon. Your task is to 0ind and return a fulcrum position in this list of weights so that when balanced on that position, the total torque of the items to the left of that position equals the total torque of the items to the right of that position. The item on the fulcrum is assumed to be centered symmetrically on the fulcrum, and does not participate in the torque calculation. In physics, the torque of an item with respect to the fulcrum equals its weight times distance from the fulcrum. If a fulcrum position exists, return that position. Otherwise return -1 to arti0icially indicate that the given items cannot be balanced, at least without rearranging them. items Expected result [6, 1, 10, 5, 4] 2 [10, 3, 3, 2, 1] 1 [7, 3, 4, 2, 9, 7, 4] -1 [42] 0…arrow_forwardarrow_back_iosSEE MORE QUESTIONSarrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT