AP Computer Science 1.5 Classes and Objects

AP Computer Science: Classes and Objects Drill 1, Problem 5. Which of the following will run without producing an error message?

APAP Computer Science
AP Computer ScienceClasses and Objects
Computer ScienceAP Computer Science
LanguageEnglish Language
Test PrepAP Computer Science

Transcript

00:25

yourself and let's Just go Okay Java syntax police Slightest

00:33

mistake and they'll be all over us Cool All right

00:36

Good afternoon officer Beautiful day isn't it Uh he wasn't

00:41

even looking this way Anyhow we've got a question of

00:43

syntax to deal with Which of these snippets will run

00:46

without producing an error message Alright well starting a simple

00:50

one t one time object is being created properly It

00:55

uses the keyword nu to denote that new time object

00:59

with the parameters or eight Thirty six and fifteen Essentially

01:03

we're holding on to the time of eight Thirty six

01:06

and fifteen seconds Invariable t want the next line creates

01:10

another time object named t to and gives it the

01:12

same value list one the conan option one will work

01:16

despite being a little redundant simple to creates a time

01:20

object called t one with no value and creates t

01:23

to which equals d want no objects have no value

01:28

kind like baseball cards and congressmen Everybody likes baseball cards

01:32

Yeah despite that this code will actually run albeit pointlessly

01:37

so far both option one into will run All right

01:40

Looking at our potential answers there was no option for

01:42

all of the sniff it's working properly From that we

01:46

can reduce their snippet Three won't work but we've got

01:48

to check it anyway for the first half of simple

01:50

three creates a time object with a null value which

01:53

is fine as we just learned But the second half

01:55

greets and manager called my seconds right here and attempts

01:59

to platform a to string operation on team one essentially

02:03

it's trying to take the data in variable t one

02:06

and represented as a securing being the t one has

02:10

no value there's nothing to represent and you'll get an

02:13

error Simple three doesn't work and he is definitely our 00:02:16.495 --> [endTime] answered Jesus