AP Computer Science 1.2 Inheritance, Abstraction, and Polymorphism

APCS: Inheritance, Abstraction, and Polymorphism Drill 1, Problem 2. Which of the following is the correct way to begin writing your class?

APAP Computer Science
AP Computer ScienceInheritance, Abstraction, and Polymorphism
Computer ScienceAP Computer Science
LanguageEnglish Language
Program AnalysisProgram correctness
Test PrepAP Computer Science

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