Mark As Completed Discussion

One Pager Cheat Sheet

  • Object-Oriented Programming (OOP) provides special functions to help save time and effort when coding, such as getters and setters for classes, as demonstrated in the example of Shape and its subclasses.
  • Constructors are special-purpose methods used to set initial values and perform initialization tasks during object instantiation.
  • A default constructor is a method (instantiated with new ClassName()) that initiates an object, which can be overridden by the user if desired.
  • The Copy Constructor is used to create a new object from an existing object of the same type by passing the existing object as an argument.
  • A user-defined constructor takes one int argument and assigns it to the data member aInt in the class A.
  • **Shallow copy** copies by reference and copies the **pointer** of an array, while **deep copy** copies the data by making a *new array* for it.
  • A custom copy constructor for deep copy needs to be implemented for classes A, B and D in order to copy the primitive wrapper type and non-primitive type objects by value instead of by reference.
  • Java objects are heap-allocated and automatically garbage collected, so there is no direct equivalent of a destructor as found in languages such as C++, where explicit deallocation is used via the delete operator.
  • Usinggetter and setterfunctions ensures that values assigned to object attributes are valid and can help prevent errors from occurring when working in collaboration with other developers.
  • The correct getter function name for the algodailyIsTheBest property according to the JavaBeans convention is getAlgodailyIsTheBest.
  • Static attributes and methods provide a convenient way to share values among all instances of a class, and can be used to keep track of the number of objects created from that class.
  • A static method can be accessed from the class directly and can be useful for situations where all the objects of the class need to share state, such as keeping a count of all objects created of the same class.
  • We can compare different Shape objects by overriding the default equals method to determine equality based on their areas.
  • Overriding the toString() method allows you to return a more informative string than the default output of the class name and hash code.
  • After completing the next lesson, you will have a full understanding of the Object-Oriented Programming capabilities.