QUESTIONS AND SOLUTIONS
◉ What is Abstraction? Answer: The hiding of implementation details
and complexity / behavior, only displaying the essential information to
the user.
◉ What is Inheritance? Answer: The mechanism by which a new class
derives its properties and methods from super classes.
This can help increase code reuse by allowing similar classes to get
fields and methods from one parent class.
◉ What is Polymorphism? Answer: The ability for methods and classes
to take on various forms throughout the life of the project.
◉ What are the different types of polymorphism? Answer: Overloading:
Same method, different parameters (type, amount, or order); compile
time
Overriding: Same method, same functionality, different implementation
(used in the child class instead of the parent class); run time
, IS-A rule: Child class is the same type as the parent class
◉ Static Answer: Static denotes a variable or method that lives on the
class and not created on every single object. A simpler way of putting
this is a variable or method is one per class. Every instance that is
created do not get their own and instead share the variable and
implementation of the static method.
◉ What is Casting? Answer: Explicitly converting one type of object to
another type. Larger objects must be casted into smaller objects whereas
smaller objects do not need to be.
◉ How many objects on the heap if I cast? Answer: Casting doesn't
affect the number of objects on the heap
◉ What is an Interface? Answer: A contract that is implemented by other
interfaces and classes, stating what methods and variables are to be used.
Can be used in Spring Data as a derivative for a database (without
implementation)
◉ What is an Abstract class? Answer: A class that provides halfway
implementation of the methods and as such cannot be implemented. It
must have constructors and may have concrete methods.