Object Orientated Programming Flashcards

1
Q

What are the 4 pillars of OOP?

A

Abstraction, Encapsulation, Polymorphism, Inheritance.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the default value of an object reference defined as an instance variable in an Object?

A

Null.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Why do we need constructors?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Why are default constructors required?

A

As per the java specification, java provides a default no-arg constructor. Even if we provide an overridden constructor, java still provides the default.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is returned by the constructor?

A

A constructor returns the object it created.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly