Page 1 of 1
[HD Pg 217, Sec. 8.6.1 - encapsulation]
Posted: Fri Feb 15, 2019 1:52 pm
by OCAJO1
"Encapsulation is considered as one of the three pillars of Object-Oriented Programming. The other two being Inheritance and Polymorphism."
Then where does Abstraction fall?
Re: [HD Pg 217, Sec. 8.6.1 - encapsulation]
Posted: Fri Feb 15, 2019 8:52 pm
by admin
Abstraction is a process of identifying the key characteristics of an entity. I would include it within inheritance and polymorphism. But there can be multiple views.
https://en.wikipedia.org/wiki/Object-or ... rogramming
Re: [HD Pg 217, Sec. 8.6.1 - encapsulation]
Posted: Sat Feb 16, 2019 4:39 pm
by OCAJO1
Do you know where do the exam producers come down on OOP having 3 pillars or 4?
Re: [HD Pg 217, Sec. 8.6.1 - encapsulation]
Posted: Sat Feb 16, 2019 7:40 pm
by admin
You will not be quizzed on this in the exam. So, if you like to believe that abstraction is the 4th pillar, thats fine

Re: [HD Pg 217, Sec. 8.6.1 - encapsulation]
Posted: Sat Feb 16, 2019 9:08 pm
by OCAJO1
Pillar, caterpillar - I just want to pass the DMV's lab driving conditions and to real world driving

Re: [HD Pg 217, Sec. 8.6.1 - encapsulation]
Posted: Wed Feb 20, 2019 8:09 pm
by OCAJO1
Question,
A twisted encapsulation question, which someone told me they saw on some exam. I was going to ignore it, but I figured I might as well give you a chance to ignore it too:)
Here it is,
"Describe a scenario that the fields instead of being private are public final and yet encapsulation is achieved?"
Re: [HD Pg 217, Sec. 8.6.1 - encapsulation]
Posted: Wed Feb 20, 2019 9:27 pm
by admin
Sorry, no idea what it is talking about.
Re: [HD Pg 217, Sec. 8.6.1 - encapsulation]
Posted: Thu Feb 21, 2019 12:22 pm
by OCAJO1
It read too weird in relation to the concept of encapsulation, but figured to better make sure.
Re: [HD Pg 217, Sec. 8.6.1 - encapsulation]
Posted: Thu Feb 21, 2019 2:31 pm
by OCAJO1
Right before the title, Encapsulation in Java:
class Person{
private age;
should be
class Person{
private int age;
also
shouldn't
else age = yrs;
be
else this.age = yrs;
Re: [HD Pg 217, Sec. 8.6.1 - encapsulation]
Posted: Thu Feb 21, 2019 9:45 pm
by admin
1. Yes, added to errata.
2. Not necessarily. When there is no conflict in variable names, "this" is optional if you want to refer to an instance field. Using "this." explicitly is considered better though. Explained in section 3.4.2