• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

Sybex Java OCA/OCP Practice test 8 ch10 question 76 mistake

 
Ranch Hand
Posts: 215
11
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
import java.time.*;
public class OnePlusOne {
   public static void main(String... nums) {
       LocalDate time = LocalDate.of(1, 11);
       while (time.getHour() < 1) {
           time.plusHours(1);
           System.out.println("in loop");
       }
   }
}

76. E. The LocalDate class is only for day/month/year values. It does not support time, so getHour and plusHours() do not compile, making Option E the answer.

It does not explain the fact that LocalDate.of(1, 11); does not compile because it should be LocalDate.of(1,11,1); It needs 3 arguments(int,int,int).Compile error if it has less than 3.
 
author & internet detective
Posts: 41774
887
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Confirmed and added to the errata. While this was not in the Java 11 book, we may use it for Java 17. (Dates are back in scope.)

Hopefully the editing process would have caught it this go round. But even better that you caught it first. Have two cows!
 
I will open the floodgates of his own worst nightmare! All in a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic