Win a copy of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 this week in the Programmer Certification forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

OCP Java SE 8 Programmer 2 Study Guide - Chapter 5 - Question 11

Posts: 2
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm currently reading the "OCP Oracle Certified Professional Java SE 8 Programmer II Study Guide" and just thought I'd seek further clarification on one of the review questions in Chapter 5.
In question 11 it creates a period object using:

Period p = Period.ofDays(1).ofYears(2);

This Period object represents a Period of 2 years which is identified in the answer. The answer mentions that Period does not allow chaining. Is it the case that some of the methods in the Period class can be chained such as minusDays(), minusMonths(), minusYears(), etc? If so, I'm thinking that this explanation might be clearer if it mentions that you cannot chain methods when creating a Period (ie: using the of___ methods).

Thanks for your help with this. I'm really enjoying studying for the Java SE 8 OCP exam using this book.
author & internet detective
Posts: 39613
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to CodeRanch!

That's a good point. Yes, it is only the static factory methods that can't be changed. Have a cow for the good point on a distinction.

I'd make a note for this to be clearer in our OCP 11 cert book but Oracle removed the topic from the exam:).
That's a very big dog. I think I want to go home now and hug this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!