DP Computer Science Questionbank
D.3 Program development
Description
[N/A]Directly related questions
-
19M.2.SL.TZ0.10a:
Define the term mutator method.
-
19M.2.SL.TZ0.10b:
State one additional instance variable of type
booleanwhich could be added to the classRaceas indicated above. -
19M.2.SL.TZ0.10f:
Many swimmers in the event have names that cannot be represented using basic character sets such as ASCII.
Describe one feature of modern programming languages that allows the wide range of students’ names to be represented correctly.
-
19M.2.SL.TZ0.12b:
Construct the code fragment for the given situation that will copy swimmers and times into two parallel arrays named
tempSwimmerandtempTime. -
19M.2.SL.TZ0.10e:
Construct code for the constructor of the class
Swimmerthat instantiates an object with parametersnameandschool. The event IDs should be set to “empty” and the times to 0.0 -
19M.2.SL.TZ0.12a:
Sketch the resulting
swimmerarray infinals. -
19M.2.SL.TZ0.12d:
Construct the code fragment that will copy the names of the 8 fastest swimmers in ascending order of time from the array
tempSwimmerto the arrayswimmersin the racefinals. -
17N.2.SL.TZ0.10b:
State the implication of the use of the term
staticin thePaymentclass. -
17N.2.SL.TZ0.10a:
Outline an alternative method of initializing these variables that would not require the use of the code in the constructor.
-
17N.2.SL.TZ0.10e:
The
Paymentclass methodaddFoodItem()is passed aFoodItemobject as a parameter.Construct the method
addFoodItem(). -
17N.2.SL.TZ0.10c:
With reference to two examples from the classes in the resource, explain the benefits gained by the use of different data types.
-
17N.2.SL.TZ0.10d:
Describe the purpose of the following statement:
private FoodItem[] fi = new FoodItem[100] -
17N.2.SL.TZ0.11b.i:
Construct statements, in code, that will print out the following: The number of drink items ordered by table 40.
-
17N.2.SL.TZ0.11a:
State the output after this code is executed.
-
17N.2.SL.TZ0.11b.ii:
Construct statements, in code, that will print out the following: The item code of the third food item ordered by table 2.
-
17N.2.SL.TZ0.11c:
Construct the method
findPrice(). You may assume that the item exists in the array. -
17N.2.SL.TZ0.11d:
When a customer wishes to pay the bill, the method is called. If the bill was for table 10 then the following call would be made:
double finalBill = tables[10].calculateBill(Item[] pl);Construct the
calculateBill()method. You should make use of any previously defined methods. -
18N.2.SL.TZ0.10d:
Construct the method
searchimplementing a linear search. Use the firstcompareWith()method in theArrivalobject.You may assume that an
Arrivalobject with the givenflightIDexists in the arrayinbound. -
18N.2.SL.TZ0.12b:
Construct a method
showDelayed()that outputs the IDs of all delayed flights in the arrayinboundthat have not yet landed and that have an ETA before a given timet. The timetis passed as aStringparameter. -
18N.2.SL.TZ0.12d:
When a flight is delayed, a method in
FlightManagementis used to find and update the flight with the delay and to reorganize the array so that it remains sorted for the ETA.
Describe how this method would be implemented using the methods provided. -
18N.2.SL.TZ0.12a:
Define the term method signature.
-
18N.2.SL.TZ0.12c:
Without using a sorting algorithm, construct the method
add(Arrival newArrival)that inserts anewArrivalin the sorted arrayinbound. You may assume thatnewArrivalhas been instantiated and that the arrayinboundis not full. -
19N.2.SL.TZ0.10c:
Define the term identifier.
-
19N.2.SL.TZ0.10e:
State the code fragment that instantiates an array
lineof 20Cartobjects. -
19N.2.SL.TZ0.10f:
Construct the method
public void joinLine(Cart newCart)that adds anewCarttolinein the next emptyarraylocation. You may assume thatlineis not full. -
19N.2.SL.TZ0.12b:
Construct the code for a method
split(part of the classPOSsystem), that takes an existing, non-emptyPOSlineas a parameter. It should copy every second cart from the original line into a new line. Afterwards it should delete every second cart from the original line.An example call in
POSsystemwould be:POSline number2 = split(number1), wherenumber1is an existingPOSline.You may use any method declared or developed.
-
19N.2.SL.TZ0.10g:
Construct the method
public Cart leaveLine(int n)that removes the cart at positionnfromlineby shifting down all the array entries bigger thann, before returning the indicatedCartobject. You may assume that a cart exists at positionn. -
19N.2.SL.TZ0.12c:
As a result of the simulation, the company has decided to create a new POS system for their supermarkets.
There have been discussions about adapting existing open source code when developing modules of the new POS system.
Describe two ethical issues that may arise if modules of the new POS system are developed from open source code.
-
20N.2.SL.TZ0.10a:
Outline one effect of using the modifier
staticwhen declaring a variable. -
20N.2.SL.TZ0.10d.i:
Construct code to create an instance of the
Vehicleclass that has a registration ofX1234567. -
20N.2.SL.TZ0.10c:
Outline why it is necessary to use the keyword
thisin thesetBrokenmethod of theVehicleclass. -
20N.2.SL.TZ0.10d.ii:
Construct code that sets the colour of the object created in part (i) as black.
-
20N.2.SL.TZ0.11d.i:
Construct the method
payin theVehicleclass that returns the admin fee stored in the variableAdminFeeif the vehicle has stayed for five hours or less; otherwise, it returns 0. -
20N.2.SL.TZ0.11d.ii:
Construct the method
payin theCarclass, where it uses thevehiclemethodpaybut adds the charge for the amount of time spent in the parking area. -
20N.2.SL.TZ0.11e:
The array
vehicles[]in theParkingAreaclass is used to store instances of theCarorMotorbikeclass.Outline why
Vehicleis a valid type for this array. -
20N.2.SL.TZ0.12a:
Describe, without writing code, any changes required to the
addVehiclemethod and theParkingAreaclass to make the new voucher scheme work. -
20N.2.SL.TZ0.12b:
Identify three other tests you might perform on the completed code to prove that it functions correctly.
-
20N.2.SL.TZ0.12c:
The
removeVehiclemethod of theParkingAreaclass searches in the array for aVehicleobject with a specified registration plate, then removes it by setting that array index tonull.The method returns a reference to the
Vehicleobject that has been removed from the array, ornullif no matching registration plate was found.
Construct theremoveVehiclemethod. -
18M.2.SL.TZ0.10a:
With the use of two examples other than
private, outline how the choice of this modifier affects the way in which these variables are accessed or used. -
18M.2.SL.TZ0.11b.i:
State the output given by the following statement:
System.out.println(allPoints[2].getMemberId()); -
18M.2.SL.TZ0.11b.iii:
State the output given by the following statement:
System.out.println(allPoints[1].getAllVisits(1).getDays()); -
18M.2.SL.TZ0.11c:
Construct the method
calculateTotalPoints(), in thePointsclass, which will calculate and return the total number of points awarded so far in the current year. - 18M.2.SL.TZ0.10c: State the status level that Tim has been assigned, for 2019, following these visits.
-
18M.2.SL.TZ0.11b.ii:
State the output given by the following statement:
System.out.println(allPoints[0].getBonusPoints()); -
18M.2.SL.TZ0.10d:
State how an individual object can be identified using this array.
-
18M.2.SL.TZ0.10e:
The attribute
statusNowis assigned its correct value at the beginning of every year for existing members. It cannot be changed during the year.Construct the method
isGold()in thePointsclass, which will return whether the current status is “Gold”.
