ShmoopTube

Where Monty Python meets your 10th grade teacher.

Search Thousands of Shmoop Videos


AP Computer Science Videos 110 videos

AP Computer Science 1.1 Classes and Objects
468 Views

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.1 Inheritance, Abstraction, and Polymorphism
203 Views

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

AP Computer Science 1.1 Program Development
404 Views

AP Computer Science 1.1 Program Development. The situation in the video is an example of which of the following?

See All

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


Share It!


Description:

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

Language:
English Language

Transcript

00:00

Thank you We sneak And here's your shmoop du jour

00:05

brought to you by a degenerate pomegranate He is just

00:09

so seedy But consider the following class hierarchy Diagram fruit

00:13

berries I assume that every class in the diagram has

00:18

a default constructor with no arguments For example default constructor

00:23

for fruit is which of the following code segment will

00:27

not cause an error The we can see the choice

00:35

is incorrect off bad because swede is not a subclass

00:38

of fruit Thus we can't put a seed object into

00:41

a fruit object B is also wrong because it attempts

00:44

to put a super class into a subclass Remember this

00:47

is disallowed job of the compiler old give you an

00:50

error and try see tries to put a grape object

00:53

into a setlist through legal is great is a subclass

00:56

of scene with fruit and it's probably our answer but

00:59

let's check the others just to make sure Well george

01:01

is incorrect because well again you can't put a super

01:03

glass into a subclass Got it finally choice easy easy

01:07

to eliminate as well because it doesn't specify the type

01:10

of object that he use It hasn't declared with new

01:14

variable though choice sees our answer we can see it 00:01:18.171 --> [endTime] very very clearly

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?