Computer Program Reading Comprehension Project
U of T Computer Program Reading Comprehension Project
Bus
This program implements a Bus class.

Download files: Bus.java, TestBus.java
Areas: static


Bus.java
1/* University of Alberta (http://www.cs.ualberta.ca/) */
2/* CMPUT114(2003-2004, Fall) http://www-csfy.cs.ualberta.ca/~c114/F03 */
3
4//
5//  Bus.java
6//  CMPUT 114
7//
8//  Created by Vadim Bulitko on Mon Sep 15 2003.
9//  Copyright (c) 2003 Vadim Bulitko. All rights reserved.
10//
Displaying 10 of 78 lines
View full source


TestBus.java
1/* University of Alberta (http://www.cs.ualberta.ca/) */
2/* CMPUT114(2003-2004, Fall) http://www-csfy.cs.ualberta.ca/~c114/F03 */
3
4//
5//  TextBus.java
6//  CMPUT 114
7//
8//  Created by Vadim Bulitko on Mon Sep 08 2003.
9//  Copyright (c) 2003 Vadim Bulitko. All rights reserved.
10//
Displaying 10 of 46 lines
View full source


Question 1
When running TestBus, how many copies of the variable numInGarage are created in the memory?
Hints Solution

Question 2
In TestBus.java, what will happen if we add the statement
Bus bus3 = new Bus(true);
after
bus2 = new Bus(true);
on line 25.
Hints Solution

Question 3
If we change
Bus.askNumberInGarage();
to
bus1.askNumberInGarage();
will the program still compile?
Hints Solution

Question 4
A client programmer tries to create a subclass that extends Bus. He wants to increase the garageCapacity to 3. Can he accomplish this?
Hints Solution