Advantages of object oriented programming - correct answer - provides clear structure
- avoids repetition
- possible to create fully reusable applications
- less code, shorter dev time
Constructor, 2 types - correct answer Special method which shares the name of the
class, serves the purpose of initializing objects.
Default - no parameters
Parameterized - takes args
Copy constructor - correct answer a constructor that accepts an object of the same
class as an argument
Constructor chaining - correct answer Using this() or super(), calls another constructor
from within a constructor.
4 pillars of OOP - correct answer Abstraction — we try to obtain an abstract view of the
problem, reducing unnecessary details.
Encapsulation — process of combining data and functions into a single class. Data not
accessed directly, accessed thru functions present inside the class. Data hiding.
Inheritance — a class is based on another class and uses data/implementation of the
other class. Used for reusability.
Polymorphism — the ability to present the same interface for differing underlying data
types. Each class has different underlying data, but the interface/superclass groups
them all together, allowing them to be used in a single data structure.
Overloading - correct answer Two or more methods/constructors with the same name
but different numbers or types of parameters, or both.
Cannot overload by return type.
An example of compiler time polymorphism.
Stack memory - correct answer Used for static memory allocation and execution of a
thread.
Contains primitive values and references to objects.
Accessed in LIFO order