Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt about OCA Self Test Chapter 1, Question 7 (K&B7)

 
Andy Taufel
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pg. 78, answer to question 7 is given to be options (C) and (D). I am thinking option (E) is correct as well because 'boolean' is a data type not 'Boolean', unless it is assumed there is a class named 'Boolean' defined with default access in the same package or source code file as class Announce.

(This post originated in the K&B7 errata thread)
 
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
Hi Andy Taufel,

First of all, a warm welcome to CodeRanch!

Andy Taufel wrote:answer to question 7 is given to be options (C) and (D). I am thinking option (E) is correct as well

You are incorrect! The study guide is spot-on: options (C) and (D) are the correct answers. This line will compile successfully and therefore option (E) is incorrectThe primitive data type is indeed boolean (with a lower case "b"), but each primitive data type has a primitive wrapper class: boolean -> Boolean, int -> Integer, short -> Short, and so on. These primitive wrapper classes reside in the java.lang package. And (as you know) all classes from the java.lang package are implicitly imported by every Java source file. In other words, you can refer to all of the classes and interfaces in the java.lang package using their simple names. And that's why line9 successfully compiles and option (E) is incorrect.

Hope it helps!
Kind regards,
Roel
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic