###### Bookmarks

Subjects and resources that you bookmark will appear here.

Light Mode

The AP Computer Science A 5-hour live stream review is here!Β π»

Join us on May 5, 2021 for the πΆοΈ AP Computer Science A Cram Finale for a last minute review to get all your questions answered!

π

All Subjects

Β >Β

π»Β

AP Comp Sci A

Β >Β

π²

Unit 9

# 9.4 Super Keyword

Peter Cao

Other times, we are overriding or overloading a method, and then we want to borrow the superclassβs implementation of that method as a substep. Like constructors, we can also use the super keyword. When using the super keyword, we are calling the superclass's implementation of the method. This allows us to not have to duplicate code twice across multiple classes, which will save you both time and space!

## Super Keyword

Let us finish this quick rectangle class with an implementation of isEquivalent()!
```/** Represents a rectangle */ public class Rectangle extends Quadrilateral { /** Makes a rectangle given a length and width */ public Rectangle(double length, double width) { super(length, width, length, width); } @Override public double Area() { return sideOne * sideTwo; // from the constructor length is sideOne and width is sideTwo } /** Determines whether a rectangle with a given length and width is equivalent to the given rectangle */ public boolean isEquivalent(double length, double width) { return super.isEquivalent(length, width, length, width); } }```

##### πͺπ½ Are you ready for the Comp Sci exam?
Take this quiz for a progress check on what youβve learned this year and get a personalized study plan to grab that 5!
START QUIZ
Studying with Hours = the ultimate focus mode
Start a free study session
##### FREE AP comp sci a Survival Pack + Cram Chart PDF
Browse Study Guides By Unit
π
Exam Reviews
π±
Unit 10: Recursion
β
Unit 1: Primitive Types
π±
Unit 2: Using Objects
π₯
Unit 3: Boolean Expressions and if Statements
πΉ
Unit 4: Iteration
βοΈ
Unit 5: Writing Classes
βοΈ
Unit 6: Array
πΎ
Unit 7: ArrayList
π»
Unit 8: 2D Array