How did I get my Java SE8 Certification?

These are my study notes taken while preparing for Java Oracle Certified Associate exam and reading the “Oca: Oracle Certified Associate Java Se 8 Programmer I Study Guide: Exam 1z0–808” by Jeanne Boyarsky. Reading such study guide is in my opinion the best way to prepare for the exam, as it actually teaches you things you will need on the exam rather than what you need when you program in Java (which is entirely different than taking an exam, of course). Here I make notes on the stuff I found new, important or surprising.
Important things to considere during the exam
- When they ask you about compilation errors , they ask you about all of them , not the first one.
- When they ask for the “output” they can mean part of the output , it also counts (facepalm). Basically each bit of output can be a separate answer — in such case you need to mark them all.
- If there is an answer like “an exception is thrown” it still does not mean that some other outputs are not true as well, that will happen before the exception; exception is not exclusive with other answers.
- When there are no line numbers in a code snippet assume that missing imports do cause compilation errors.
public void MyClass()- this is how they may trick you, notice this is NOT a constructor since it hasvoidreturn type..StringBuilder str = "bla";- another way to trick, this does not compile- Vocabulary: legal = valid = compiles.
The book
I used the following book for studying: OCA Oracle Certified Associate Java SE 8 Programmer I Study Guide Exam 1Z0–808 by Jeanne Boyarsky and Scott Selikoff. Just about anyone I asked about a decent study guide recommended this book to me, and I gotta say: it’s worth every penny! I’ve read one other book by the same authors (which I also recommend heartily!), so I was already familiar with their style. Somehow, the authors manage to make dull, theoretical stuff like Garbage Collection, sound fun and exciting. They approach every subject with lots of humor. The book is also filled with lots of practical hands-on tips for taking the exam. You quickly get an idea what to expect on the exam, and when it comes to that, you’re not spared one bit.
Enthuware Mock exams
I told you, we’d get there right? At some point I decided that reading and learn from the book, and make the questions from the book, wasn’t enough preparation. I needed some “fake” exams to practice. Looking around at Coderanch, I saw a lot of recommendations for the Enthuware mock exams. Well, those recommendations were spot on! Basically, what you get is cross-platform software that emulates the exam-software at the Pearson VUE institute where you’ll be taking the real exam. Together with that you get a question bank with as much as 13 practice exams and a series of questions for each exam objective. The questions are tuned to be a bit harder than “the real thing”, but that’s actually great to toughen you up. The software also has a built-in chat client so you can ask questions from the good people of Enthuware.
Expect to be using this program a lot, if you want to prepare decently!
Overview by chapters
Chapter 1 Java Building Blocks
- asterisk in package import does not import child packages
- if there is class name conflict in 2 imported packages, you get compilation error : The type … is ambiguous, but it is ok, if you point to one name explicitly (e.g.
java.util.Dateandjava.sql.*); if both are explicit but collide , you get another compilation error: The import … collides with another import … {..}directly in a class is called instance initilalizer (may be static or not); instance initilalizer is also a code block- order of initialization: fields and instance initializer blocks are run in the order they appear in the file, and constructor at the end
- the opposite of primitive type is called reference type
- there is eight primitive types:
byte(from-128to127),short,int,longare respectively:8,16,32,64-bit;floatanddoubleare32and64-bit floating-point(=decimal), respectively;charis16-bit Unicode int num;- and the 32 bits is already allocated by Java
Chapter 2 Operators and Statements
- three types of operators: unary , binary , ternary , depending to how many operands they can be applied (1, 2, or 3)
- order of operator precedence (most weird ones are not required for this exam):
i++,i--++i,--i- unary
+,-,! *,/,%+,-<<,>>,>>>(shift operators)<,>,<=,>=,instanceof(relational operators)==,!=&,^,|(logical operators)&&,||(short circuit logical operators)- ternary
a ? b: c =,+=,-=,*=,/=,%=,&=,^=,!=,<<=,>>=,>>>=(assignment operators)int t = 11/3= 3! (floor)- numeric promotion
- integer multiplied by double is type double
- numeric promotion occurs actually before the operation, for any operator.
- short multiplied by short is integer (same for char) for binary operators.
Chapter 3 Core Java APIs
String
System.out.println(1 + 2 + "c");outputs3c(order of operators)- Strings are immutable (so also
final), so doing operations on them always returns a newString str.indexOf()- returns first index of occurence, or -1str.substring(inclusively, exclusively)str.startsWith()andstr.endsWith()is case sensitiveStringimplementsCharSequence
Array
- An array is an area of memory on the heap with space for a designated number of elements;
Stringis implemented as an array int[] numbers = new int[3];int[] numbers = new int[]{14,12,53};int[] numbers = new int{14,12,53};int [] numbers = new int[3];int numbers[] = new int[3];- numbers is a reference variable — it points to the array object
int a[], b;- this is oneint arrayand oneint, and is correct