• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

OCA Java SE 8 Programmer I Study Guide - Chapter 4 - review question 8

 
Piet Souris
Rancher
Posts: 1521
32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Apologies if this question has come up before, but I could not find anything about it. Here is:

The statement is statement E: "Immutability uses private instance variables" and the question: true or false. According to the book this statement is true.

But if you have only final immutable variables that are not private, don't we have an immutable class as well? For instance:



So I opted for 'false'. What am I missing here? It is a mixed question and includes encapsulation as well.

 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Piet,
The idea is that a *good* immutable class is well encapsulated too. You are correct that your example is immutable. You won't see that on the exam though.
 
Piet Souris
Rancher
Posts: 1521
32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm, although I understand what you mean, my problem is that that idea is not mandatory. But if such a question is absent from the exam, then I have nothing to fear (I hope). Thanks!
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Piet,
You'll be fine. they include a very limited subset of design patterns and principles on the exam.
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Piet Souris wrote:But if you have only final immutable variables that are not private, don't we have an immutable class as well?

True! But the statement mentions "variables", not "immutable variables".
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic