[HD Pg 217, Sec. 8.6.1 - encapsulation]

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
OCAJO1
Posts: 221
Joined: Mon Nov 26, 2018 2:43 pm
Contact:

[HD Pg 217, Sec. 8.6.1 - encapsulation]

Post 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?

admin
Site Admin
Posts: 10388
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: [HD Pg 217, Sec. 8.6.1 - encapsulation]

Post 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

OCAJO1
Posts: 221
Joined: Mon Nov 26, 2018 2:43 pm
Contact:

Re: [HD Pg 217, Sec. 8.6.1 - encapsulation]

Post by OCAJO1 »

Do you know where do the exam producers come down on OOP having 3 pillars or 4?

admin
Site Admin
Posts: 10388
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: [HD Pg 217, Sec. 8.6.1 - encapsulation]

Post 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 :)

OCAJO1
Posts: 221
Joined: Mon Nov 26, 2018 2:43 pm
Contact:

Re: [HD Pg 217, Sec. 8.6.1 - encapsulation]

Post by OCAJO1 »

Pillar, caterpillar - I just want to pass the DMV's lab driving conditions and to real world driving :)

OCAJO1
Posts: 221
Joined: Mon Nov 26, 2018 2:43 pm
Contact:

Re: [HD Pg 217, Sec. 8.6.1 - encapsulation]

Post 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?"

admin
Site Admin
Posts: 10388
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: [HD Pg 217, Sec. 8.6.1 - encapsulation]

Post by admin »

Sorry, no idea what it is talking about.

OCAJO1
Posts: 221
Joined: Mon Nov 26, 2018 2:43 pm
Contact:

Re: [HD Pg 217, Sec. 8.6.1 - encapsulation]

Post by OCAJO1 »

It read too weird in relation to the concept of encapsulation, but figured to better make sure.

OCAJO1
Posts: 221
Joined: Mon Nov 26, 2018 2:43 pm
Contact:

Re: [HD Pg 217, Sec. 8.6.1 - encapsulation]

Post 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;

admin
Site Admin
Posts: 10388
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: [HD Pg 217, Sec. 8.6.1 - encapsulation]

Post 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

Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests