ShmoopTube

Where Monty Python meets your 10th grade teacher.

Search Thousands of Shmoop Videos


Program Analysis Videos 41 videos

AP Computer Science 4.4 Inheritance, Abstraction, and Polymorphism
174 Views

AP Computer Science 4.4 Inheritance, Abstraction, and Polymorphism. Which of the following code segments will not cause an error?

AP Computer Science 1.4 Inheritance, Abstraction, and Polymorphism
190 Views

AP Computer Science 1.4 Inheritance, Abstraction, and Polymorphism. Which of the following code segments will not cause an error?

AP Computer Science 1.5 Program Development
204 Views

AP Computer Science 1.5 Program Development. Utilize functional decomposition to write a function.

See All

AP Computer Science 1.1 Inheritance, Abstraction, and Polymorphism 203 Views


Share It!


Description:

AP Computer Science 1.1 Inheritance, Abstraction, and Polymorphism. Which of the following are correct?

Language:
English Language

Transcript

00:00

Thank you We sneak and here's your smoke Do sure

00:05

try to sit up straight Just imagine you're a glam

00:08

metal bands hair Consider the following class hierarchy Upward arrows

00:12

indicate an inheritance relationship which of the following are correct

00:17

And here the potential answers Yeah All right as the

00:22

problem states up arrows indicated inheritance relationship and we already

00:27

know that inheritance is just a big fancy word for

00:30

is a relationship No fast song is a song slow

00:34

song is a song too and we can go step

00:37

further and say power ballad is a slow song which

00:42

is a song Well we could extend this even further

00:44

by saying november rain is a power ballad november rain

00:48

than inherits any and all of the fields methods and

00:51

nested classes from power ballad which inherits from slow song

00:56

which inherits from song for exam song would contain members

01:00

that are relevant all songs and every subclass of song

01:03

things like are this name instruments song blank and so

01:07

on things that every song will have Well november rain

01:11

would be extremely specific like emotional axl rose vocal which

01:16

is something out every single half aside from simply knowing

01:19

their relationship between classes It's also important to know how

01:22

to properly declare and create a variable setting it all

01:27

up typically goes like this class variable named equals new

01:32

glass for supplies Yeah right left side of the equation

01:36

declares a variable to refer to An object song a

01:39

for example lets the compiler know that you're going to

01:42

use a to refer to data of the variety song

01:45

but that object doesn't actually yet exist On the other

01:49

side of the equation we get down and dirty and

01:51

actually a sign an object to that variable A new

01:54

power ballad for example would be created with song a

01:57

equals new power valid All right the question is asking

02:00

us which of these three option for declaring in creating

02:03

variables are correct starting with option one song a equals

02:07

new power balance and that's what we just did a

02:09

second ago and it works too and song be equals

02:12

New slow jam Yeah perfectly good way of creating a

02:15

slow jam Another good way would involve candles rose petals

02:19

and a saxophone solo But this is a little quicker

02:22

option One is good Option two is a little weird

02:25

It has as creating a slow song and power valid

02:28

and having them equal new song and slow song objects

02:32

but that's just not gonna fly the left side of

02:35

the equation declares variables name and its class and the

02:38

right side actually creates the object Option two is trying

02:42

to declare a variable of the type that's a subclass

02:44

of the actual object or creating that's like declaring that

02:48

you're going to be dracula for halloween But he actually

02:50

dress up some generic monster The option to option three

02:55

works like option one declaring variables and b to be

02:57

songs and then creates new fast song and slow song

03:01

objects So yeah three work with options One of three

03:04

working and to being wrong That makes the our answer

Related Videos

AP Computer Science 1.2 GridWorld Case Study and APIs
493 Views

AP Computer Science 1.2 GridWorld Case Study and APIs. What is the direction of the actor?

AP Computer Science 1.4 Standard Algorithms
200 Views

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
191 Views

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
204 Views

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
191 Views

AP Computer Science 4.2 Standard Algorithms. What kind of algorithm is the following?