ShmoopTube
Where Monty Python meets your 10th grade teacher.
Search Thousands of Shmoop Videos
Computer Science Videos 112 videos
Just as you move your furniture into a new house before spending the night, you’ve got to spend a little time setting up your environment when yo...
Doubles and ints. At first glance, it may look like this video will be about baseball and football statistics. But they're actually computer scienc...
AP Computer Science: Classes and Objects Drill 1, Problem 1. Which of the following is a correct {/* Implementation */} for the isInsect method?
AP Computer Science 1.2 Program Development 293 Views
Share It!
Description:
AP Computer Science 1.2 Program Development. Which of the following is correct?
Transcript
- 00:00
Thank you We sneak and here's your shmoop du jour
- 00:05
brought to you by super class is not to be
- 00:07
confused with supper classes But if you're already wearing your
- 00:11
lobster bin well leave it all right This question is
- 00:15
based on the following class hierarchy diagram this one Note
Full 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
Related Videos
AP Computer Science 1.2 GridWorld Case Study and APIs. What is the direction of the actor?
AP Computer Science 1.4 Standard Algorithms. How many times will mystery be called for mystery(n) for n > 1?
AP Computer Science 2.3 Classes and Objects. Which of the following is correct implementation of the Country class?
AP Computer Science 3.4 Inheritance, Abstraction, and Polymorphism. Which of the following will satisfy the conditional if statement for boo, str,...
AP Computer Science 4.2 Standard Algorithms. What kind of algorithm is the following?