answer these mcqs case study is given above
19 Which is TRUE for the statement: Car p1= new Car("WL05GMF","Toyota",35000); a) this statement is NEVER found in the GarageList class b) this statement is ONLY to be found in the GarageList class c) this statement is LIKELY to be found in the Car class d) this statement is LIKELY to be found in the CarTest class e) this statement is LIKELY to be found in the Date class Your answer letter: 20 Which of the following is TRUE about definitions of methods in GarageList a) definition of getRegistration()in findCar() can be found in Car b) definition of add() in addCar()can be found in Car c) definition of getRegistration()in findCar() can be found in ArrayList d) definition of get() in findCar() can be found in Car e) definition of size()in findCar() can be found in GarageList Your answer letter: 21 The following statement is correct and found in ListRunner Car mine = new Car(); Which of the following is TRUE a) mine is the class b) Car()is a call to a constructor c) Car is a call to a constructor d) Car()is the class e) Car() is an object of the Car class Your answer letter: 22 Which of the following is FALSE a) if do not include import java.util.*; before the class definition, using an ArrayList would cause a syntax error if import java.util.*; is included before the class definition, using an ArrayList would NOT cause a syntax error b) In declaring an ArrayList object, <E>must be replaced by the class of objects to be stored c) get(indx) is a method call to return an object stored at position indx in an ArrayList d) Retrieving an item from an ArrayList using a field value requires code which performs a "search" e) The number of items in an ArrayList is given by the public variable size Your answer letter:
SECTION B Case Study A This section relates to the Java programming language. TestRenner ListRunner CarTest Garage List Car Date public class Car { private String regno; private String make; private Date registered; private int milage; private double cost; private double cost Paid; public Car (String reg, String mk, int mls) { make = mk; regno = reg; milage = 0; cost = 0; cost Paid = 0; registered = null; } public String getRegistration () { return regno; } public void setCost (double f) { cost = f; 1 //remaining code omitted but could include: Car(), updateMilage (). toString(), getMake () and other accessors/mutators/constructors } // continued below
public class GarageList private String name; private int areaCode; private ArrayList<Car> carList = new ArrayList<Car>(); public GarageList(String nme, int cd) name = nme; areaCode = cd; 1 public void addCar (Car s) carlist.add(s); 1 public Car findCar (String cno) for (int index = 0; index < carlist.size(); index++) { Car temp = carlist.get (index); tempreg = temp.getRegistration (); if (cNo.equals (tempReg)) { return temp; } } return null; } //remaining code omitted }
19 Which is TRUE for the statement: Car p1= new Car("WL05GMF","Toyota",35000); a) this statement is NEVER found in the G
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
19 Which is TRUE for the statement: Car p1= new Car("WL05GMF","Toyota",35000); a) this statement is NEVER found in the G
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!