AP Computer Science 1.2 Program Development

AP Computer Science 1.2 Program Development. Which of the following is correct?

APAP Computer Science
AP Computer ScienceProgram Development
Computer ScienceAP Computer Science
LanguageEnglish Language
Object-Oriented Program DesignProgram and Class Design
Test PrepAP Computer Science

Transcript

00:19

that in open air own denotes an inheritance relationship and

00:22

a closed aero denotes a composition relationship though which of

00:26

the following is correct And here the potential answers has

00:32

there Mike all right well here we have a question

00:35

about a pretty basic class hierarchy structure whenever something like

00:39

this crops up It's important to remember that there are

00:41

two kinds of relationships Glasses can have inheritance and composition

00:47

Except those two words are needlessly convoluted and actually pretty

00:52

vague when you think about it So they often get

00:55

referred to as isa and has a relationship when two

01:00

classes related one either is the other or has the

01:03

other okay Subtle but important Consider this The class limb

01:08

is related to the classes of arm and leg An

01:12

army is a limb just a more specific kind of

01:15

limb and sore legs A foot is not a leg

01:18

But they're still related instead of leg has a foot

01:22

got it Give yourself a hand We've got a leg

01:25

up and are ready to go toe to toe with

01:27

questions So here we have our hierarchy of classes and

01:31

we can see that north american country is a country

01:35

is seeing yousa as our european country and asian country

01:39

East asian country is an asian country too They're our

01:44

inheritance relationships and our denoted by the downward open arrows

01:48

these things state is not a north american country However

01:53

this is a has a situation where north american country

01:57

has a state north american country can also have a

02:02

territory or province thes composition relationships air denoted by upward

02:06

close aargh and we're being asked which of the following

02:10

is correct so let's look alright option a says north

02:13

american country is a super class of state not quite

02:16

north american country has a state so it's a composition

02:20

relationship rather than an inheritance relationship No super classes around

02:24

here option b r v says there is a has

02:28

a relationship between asian country and east asian country We'll

02:32

not it off east asian country is an asian country

02:36

is this one out of here Option c there is

02:38

a has a relationship between north american country and province

02:42

Yes the diagram pretty clearly shows that's the case upward

02:48

arrow and everything Yep let's Check the others though right

02:50

option d says state is a subclass of country well

02:54

no countries way up here in states way down here

02:58

So north american country has a state but it's not

03:01

the same thing He makes almost the same error reaching

03:04

all the way across The diagram in claiming country has

03:07

a territory well no not at all North american country

03:10

has a territory but country doesn't That means sea is

03:14

definitely our answered North american country has province and ice

03:18

hockey and mounties and ryan gosling's from there and polar

03:21

bears and kids in the hall and the roots and

03:24

half a niagara falls And that life is a highway 00:03:27.27 --> [endTime] song