AP Computer Science 1.2 Inheritance, Abstraction, and Polymorphism
Recommendation
Want a study guide too?
APCS: Inheritance, Abstraction, and Polymorphism Drill 1, Problem 2. Which of the following is the correct way to begin writing your class?
AP | AP Computer Science |
AP Computer Science | Inheritance, Abstraction, and Polymorphism |
Computer Science | AP Computer Science |
Language | English Language |
Program Analysis | Program correctness |
Test Prep | AP Computer Science |
Transcript
efforts to reduce your carbon footprint Which of the following
is a correct way to begin writing your class carbon
footprint like tires All right And here the potential answers
public clan All right well the key to answering this
question is knowing the syntax of defining a subclass in
java But what is a sub class submarine class Well
it's a lot like a normal class except a subclass
also inherits things from the super class it's extending from
so once we get set up and we're messing around
with our new bicycle class we'll be able to use
the access or methods of vehicle that we've already written
Got it all right Well this idea is known as
inheritance in object oriented programming and it doesn't involve trying
to make your distant ninety eight year old relatives think
you're interesting Anyhow this is a question of syntax and
that's In texas public class new subclass extends class way
know for a fact that bicycle is intended to be
a subclass of vehicle It hangs down like fruit on
a tree so he is certainly out He creates a
class called vehicle that extends from bicycle and it's the
wrong way around Option a is also an option a
uses new to declare the subclass bicycle exist but the
question is asking us to define it similar words but
two very different things A declaration simply says something exists
but doesn't describe what the class or function actually does
The question was asking us to define the class Instead
option b and c use the word super rather than
extends which isn't proper syntax whatsoever So that just leaves
us with d which has both the correct syntax and 00:02:00.796 --> [endTime] the classes in their proper order They were walking