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 Inheritance, Abstraction, and Polymorphism 369 Views
Share It!
Description:
APCS: Inheritance, Abstraction, and Polymorphism Drill 1, Problem 2. Which of the following is the correct way to begin writing your class?
Transcript
- 00:00
Sorry And here's your shmoop to use your brought to
- 00:05
you by object oriented programming It's got class that's really
- 00:10
funny the computer science majors around us or just rolling
- 00:13
on the floor right All right you would like to
- 00:15
define a subclass called bicycle as part of your ongoing
Full Transcript
- 00:19
efforts to reduce your carbon footprint Which of the following
- 00:23
is a correct way to begin writing your class carbon
- 00:27
footprint like tires All right And here the potential answers
- 00:32
public clan All right well the key to answering this
- 00:37
question is knowing the syntax of defining a subclass in
- 00:40
java But what is a sub class submarine class Well
- 00:44
it's a lot like a normal class except a subclass
- 00:47
also inherits things from the super class it's extending from
- 00:51
so once we get set up and we're messing around
- 00:53
with our new bicycle class we'll be able to use
- 00:55
the access or methods of vehicle that we've already written
- 00:59
Got it all right Well this idea is known as
- 01:01
inheritance in object oriented programming and it doesn't involve trying
- 01:05
to make your distant ninety eight year old relatives think
- 01:08
you're interesting Anyhow this is a question of syntax and
- 01:12
that's In texas public class new subclass extends class way
- 01:18
know for a fact that bicycle is intended to be
- 01:20
a subclass of vehicle It hangs down like fruit on
- 01:24
a tree so he is certainly out He creates a
- 01:26
class called vehicle that extends from bicycle and it's the
- 01:29
wrong way around Option a is also an option a
- 01:32
uses new to declare the subclass bicycle exist but the
- 01:36
question is asking us to define it similar words but
- 01:39
two very different things A declaration simply says something exists
- 01:43
but doesn't describe what the class or function actually does
- 01:47
The question was asking us to define the class Instead
- 01:51
option b and c use the word super rather than
- 01:54
extends which isn't proper syntax whatsoever So that just leaves
- 01:58
us with d which has both the correct syntax and 00:02:00.796 --> [endTime] the classes in their proper order They were walking
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?