Object Orientated Programming Flashcards
What are the 4 pillars of OOP?
Abstraction, Encapsulation, Polymorphism, Inheritance.
What is the default value of an object reference defined as an instance variable in an Object?
Null.
Why do we need constructors?
Java is an OOP language, in which we create and use objects. A constructor is a piece of code, which is used to create and set the initial state of an object. Without a constructor there is no way to create an object. Java provides a default constructor for every object.
Why are default constructors required?
As per the java specification, java provides a default no-arg constructor. Even if we provide an overridden constructor, java still provides the default.
What is returned by the constructor?
A constructor returns the object it created.