COSI 12b Study Guide - Midterm Guide: Object-Oriented Programming

125 views2 pages

Document Summary

Shadowing indicates two variables with the same name and scope. The this keyword fixes shadowing. if (o instanceof point) { Point other = (point) o; return ; } Coupling (class dependency on other classes) should be limited. Once a constructor is written in a superclass it must be written in the subclass or else it will not compile. There are two solutions, either add a default constructor in the superclass or add the constructor from the superclass to the subclass. A subclass can call a superclass"s constructor with super();. To add a variable to a subclass"s constructor it should always be after the call to the superclass"s constructor, never before. A variable of type t can hold an object of any subclass of t. The employee1 object can only use employee methods, not lawyer methods. However, it will use any overridden methods from lawyer.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers

Related Documents

Related Questions