Instructions: Answer the following questions one at a time. After answering each question, check your answer (by clicking on the check-mark icon if it is available) before proceeding to the next question.
Getting Ready: Before going any further, you should:
downloads
directory/folder). In most browsers/OSs, the
easiest way to do this is by right-clicking/control-clicking on
each of the links above and then selecting If you are completing this lab on a lab computer, and this is the first time (this semester) that you are using VSCode on a lab computer, follow the instructions for configuring VSCode for this course that are available on the course "Help" page. (Note that Java and VSCode have already been installed on the lab computers, it just hasn't been configured for this course.)
If you are using your own computer and you have not yet done so, install and configure all of the tools following the instructions in the course "Help".
lab01
) under the src
directory.
CS159
, src
, and the
directory/folder you created for this lab.
TripRecord.java
by
double-clicking on the file with that name in the explorer view.
package
statement so that it is consistent
with the directory/folder you created for this lab (e.g.,
package lab01;
) and save the file.
TripRecord
class?
passengers
.
private
is a visibility/accessibility modifier
in Java so, VSCode presents it in a special color.
passengers
. What happens?
50.5
is assigned to
this.passengers
. What is the syntax error?
(int) 50.5
is assigned to
this.passengers
. Why isn't this a syntax error?
duration
is assigned to
this.passengers
. What is the syntax error?
passengers
is assigned to
this.passengers
(as it was originally).
5
is assigned to
this.length
. Why isn't this a syntax error?
getPassengers()
method so that it returns the value 10.9
. What
is the syntax error?
passengers
to passenger
in
the declaration statement. How
many warnings/errors are there now (and what are they)?
private
instance
attribute of type int
named passengers
length = length;
.
What is the warning/error?
this
in the
assignment statements in the constructor?
.
in the assignment statements in the constructor?
length
. What change did you
make?
duration
is assigned to the instance attribute
named length
. What change did you make?
length
. What change did you make?
passengers
in
the block comment for the constructor to passenger
and save the file. Is this a style defect?
passengers
correctly). What happens?
getDuration()
method to
GetDuration()
. Is this a style defect?
getLength()
and
getDuration()
methods without changing the methods themselves
and save the file. Is this a style defect?
TripRecord.java
and pull down to Open Timeline. What
happens?
TripRecord.java
.
What happens?
Copyright 2024