answers graded A+
Default values - correct answer ✔✔Any method or function can provide default values for its
parameters in the function signature
We can add methods to our classes to create ___ that ___ methods that can work on that data -
correct answer ✔✔Objects, encapsulates
If member variables are public, we can't - correct answer ✔✔Change the internal
representation (ex: Person class with age variable set as number, but later on I change it to
string, this messes the code all up). Accessible from anywhere. Can access public members in
subclass
Super - correct answer ✔✔Calls constructor of parent and rages whatever args as constructors
If they are private, - correct answer ✔✔Hides info from users. Our class will have a public
interface which may be separate from its internal representation. Can be changed so long that
the public interface still works as expected (since users don't have direct access anyways)
How to deep copy? - correct answer ✔✔Teach each class how to clone itself, then use these
methods if we have a class that contains another class (composition)
What if it contains a primitive type inside? - correct answer ✔✔If we use spread it creates
shallow copy. We need to iterate through the array given, clone each, create a new array of
clones that we can pass to constructor of the new object
, Method - correct answer ✔✔A function that is associated with an object and called using dot
notation.
Composition - correct answer ✔✔When a class contains another class we add the second class
as a property of the first
Inheritance - correct answer ✔✔Build complex hierarchies of objects in order to define new
types that are a type of some existing type
is-a vs. has-a - correct answer ✔✔- Is-A: used to describe -> child of a parent class
- Example: Inheritance
Phone class is a (or is a type of) Device (also a class)
- Has-A:
-> Is used to describe the characteristics that define an object
data members that have a relationship to the class
-> Example: composition
Class Color is used in Class Point. The point has a (or contains a) color
Extends - correct answer ✔✔creates the inheritance relationship between subclass (child) and
superclass (parent). What we extend- the superclass
What we create by extending- subclass
How to call superclass constructor within subclass constructor - correct answer ✔✔Super()
takes same args as constructor of superclass
Private - correct answer ✔✔Only accessible within the class.