AP Computer Science 1.5 Classes and Objects
Recommendation
Want a study guide too?
AP Computer Science: Classes and Objects Drill 1, Problem 5. Which of the following will run without producing an error message?
AP | AP Computer Science |
AP Computer Science | Classes and Objects |
Computer Science | AP Computer Science |
Language | English Language |
Test Prep | AP Computer Science |
Transcript
yourself and let's Just go Okay Java syntax police Slightest
mistake and they'll be all over us Cool All right
Good afternoon officer Beautiful day isn't it Uh he wasn't
even looking this way Anyhow we've got a question of
syntax to deal with Which of these snippets will run
without producing an error message Alright well starting a simple
one t one time object is being created properly It
uses the keyword nu to denote that new time object
with the parameters or eight Thirty six and fifteen Essentially
we're holding on to the time of eight Thirty six
and fifteen seconds Invariable t want the next line creates
another time object named t to and gives it the
same value list one the conan option one will work
despite being a little redundant simple to creates a time
object called t one with no value and creates t
to which equals d want no objects have no value
kind like baseball cards and congressmen Everybody likes baseball cards
Yeah despite that this code will actually run albeit pointlessly
so far both option one into will run All right
Looking at our potential answers there was no option for
all of the sniff it's working properly From that we
can reduce their snippet Three won't work but we've got
to check it anyway for the first half of simple
three creates a time object with a null value which
is fine as we just learned But the second half
greets and manager called my seconds right here and attempts
to platform a to string operation on team one essentially
it's trying to take the data in variable t one
and represented as a securing being the t one has
no value there's nothing to represent and you'll get an
error Simple three doesn't work and he is definitely our 00:02:16.495 --> [endTime] answered Jesus