Ocp java se 8 kathy sierra pdf free download
So when you see code like this 3. They were trying to help you do less scrolling. Why Is There so Much Memorization? So why do I have to memorize API stuff for the exam? This knowledge will make you a much better programmer. For instance, when we wrote this book, we had forgotten some of the API details that we needed to write the questions. Language Memorization We hear similar complaints about having to memorize language details. The second reason is similar to the API discussion.
The bottom line is this: after studying for this exam, you will be a better Java programmer, and you will use the language more like it was intended. Although we said this in the the number of correct answers can help introduction, it bears repeating. In the real you narrow down the choices and make a exam, EVERY multiple choice question will better guess. But in this book, we there are. In other words, the real exam will want to toughen you up. On the real exam, you On both the real exam and in our drag- should expect 15 to 20 percent of your and-drop questions, there may be more questions to be drag-and-drop style.
In this than one correct answer. How did you score on the first assessment exam? If you needed to do more studying, did you? Given that, if your results on the first exam were borderline or worse, you should have put in some serious study time before trying this exam.
On the other hand, if you did really well on the first assessment exam, then this one should give you a truer sense of your readiness for the real exam. Given a directory structure: - baseDir - testDir - subDir2 - Shackelton. Choose three. Line 12 is correct as it stands. Line 14 is correct as it stands. The program must be invoked from the baseDir directory.
The program must be invoked from the testDir directory. Line 12 must use File. Line 14 must use the method fileExists instead of exists. The output will include "" D. The output will include "" E. The output will include the number of milliseconds from January 1, until today. The output will contain " An exception will be thrown at runtime.
Given that the current directory is bigApp, and the following directory structure: bigApp -- classes -- com -- wickedlysmart -- BigAppMain. BigAppMain B. BigAppMain D. BigAppMain E. BigAppMain F.
BigAppMain G. BigAppMain 7. Both fragments produce the same output. Both fragments will end in about the same amount of time. Compilation fails, regardless of which fragment is inserted.
Regardless of which fragment is inserted, output ends once the Error is thrown. Regardless of which fragment is inserted, output continues after the Error is thrown. Compilation fails due to an error on line 3. Compilation fails due to accessing x on line Compilation fails due to accessing y on line Given: 4.
Class BeSafe can create many instances of SafeDeposit. Class BeSafe can create only one instance of SafeDeposit. D, F C, E Line 14 must use the method fileExists instead of exists Answer for Objective 3. In order to find the Shackelton. The pathSeparator field in the File class is used to separate path lists, not directories in paths, and the correct method is File.
If line 4 was removed, the answer would be B, C, D, and E. The invocation of parse will return BigAppMain Answer for Objective 7. F will be a tiny bit slower than D, because the.
Answer for Objective 4. In either case, before the Error is thrown a new thread is created, and the new thread will execute independently of the Error. Method-local inner classes can use variables from their enclosing methods, only if they are marked "final". A method-local inner class can be instantiated only after it has been declared.
It is legal to use private members from the enclosing class. Typically, if you invoked the program without a command-line argument, an exception would be thrown and the output would be "done finally".
If you invoked the program with a command-line argument, no exception would be thrown and the finally statement would produce the output: "finally". If, however, doStuff did something like call System. The generic declaration at the class level says that Carpet can accept any type which is either B or a subtype of B.
A and B run because assertions were not enabled. C and E run because an instance of class One is not created. G runs because assertions are enabled only for class Two. F throws an AssertionError because assertions were enabled specifically for class One, and an instance of class One was created. Answer for Objectives 5. F is correct because "code" is private and there is no setter.
Note: expect to see questions that cover more than one objective! After that second has elapsed, one of the threads will invoke do2 , and the other will have to wait. Once the thread that ran do2 first is done with do2 , the other thread can run do2.
Thereafter, the threads will alternate running do1 and do2 , but they are able to run mostly simultaneously. Table 2. We recommend you do a bit more studying. Question Management Before you start the clock, give yourself a few blank sheets of paper and a couple of pencils.
You will get some sort of first. If one center offers you a small dry writing equipment at the testing center. The standard is. If you can choose between advantages of pencil and paper over a a few centers that are close to you, call small dry erase board are enormous! Time Management Some candidates report that three hours for the exam is plenty of time.
Some candidates even candidates who do well report that they felt pressed for time. Of course, some questions will take very little time, but some questions like threads and garbage collection might take more. For instance, sometimes in the exam engine. Also, as in the real exam, sometimes there will be more than one way to correctly arrange the fragments.
You will receive full credit for ANY of the correct answer arrangements. Bang will execute for a second or two. Bang will execute for at least 10 minutes. Thread t1 will almost certainly be the last thread to finish. Thread t1 will almost certainly be the first thread to finish.
Line I will compile. Line II will compile. Line III will compile. Line IV will compile. Class Numinor will NOT compile. Volume v; 4. Class A does not compile. Class B does not compile. Class C does not compile. Class D does not compile. Class E does not compile. Class F does not compile. Compilation succeeds for all of the classes.
Given that "it, IT" and "pt" are valid Locale codes, and given: DateFormat df; FULL, l ; Classes from the java. There are other errors in the code. Given: 5. An uncaught IllegalArgumentException is thrown. The output could be ted bob alice B. The output could be bob alice carol C. The output could be bob carol ted alice D. String color; 5.
Without overriding hashCode , the code will not compile. As it stands, the equals method has been legally overridden. As it stands, the Chilis class legally supports the equals and hashCode contracts. If hashCode was correctly overridden, it would make retrieving Map entries by key easier.
The class is well encapsulated. The setCity method is an example of loose coupling. The setCity method has better encapsulation than setName. The setCity method is cohesive; the setName method is not.
Given the current directory is bigApp, and the directory structure: bigApp -- classes -- Cloned. Compilation fails due to an error on line 2. Compilation fails due to an error on line 4. The code runs in an endless loop. Line 6 B. Line 7 C. Line 10 D. Line 11 E. Line 12 F. Line 13 0. The java. Properties class is conceptually more like a List than like a Map. Given the following directory structure: test - - Finder.
Compilation succeeds and the code runs without exception. Compilation succeeds and an exception is thrown at runtime. MyApp is-a Employee. MyApp is-a Mungeable. MyApp has-a Employee. MyApp has-a Mungeable. The code is loosely coupled. The Employee class is well encapsulated. Compilation fails due to a single error. Compilation fails due to multiple errors. An exception is thrown with no other output. Compilation fails due to error s in the code.
After throwing error s , t3 will most likely complete before t4. After throwing error s , t4 will most likely complete before t3. The code will throw one error and then no more output will be produced. The code will throw two errors and then no more output will be produced.
An AssertionError is thrown. A NullPointerException is thrown. An IllegalArgumentException is thrown. String s; Beach LaSelva Beach B. Beach LaSelva followed by an exception. Compilation fails due to an error at line 5. Compilation fails due to an error at line 6. Compilation fails due to an error at line 8. Compilation fails due to an error at line When using the java.
Console class, which are true? Objects of type java. Console are created using a constructor from the same class. Console are created using a method from the java. File class. System class.
Object class. The method s designed to read passwords can optionally disable the echoing of user input. The method s designed to read passwords return a char[].
Integer i2; 7. Integer i3; 8. String doStuff throws Exception; 5. Risky doCrazy ; 6. The Risky interface will not compile. The Bungee. An uncaught exception is thrown at runtime. All three invocations will return valid octal numbers.
None of the invocations will return valid octal numbers. All three invocations will return the same set of valid octal numbers. An exception could be thrown.
The code could cause a deadlock. The output could be 1 3 4 2 E. The output could be 1 3 2 4 F. The output could be 3 1 4 2 G. Fill in the blanks using the fragments below, so that the code compiles and produces the output: "1 3 2 3 2 " Note: You might not need to fill in all of the blanks. Workings void tock The assertion on line 5 is appropriate. The assertion on line 13 is appropriate. These classes appear to have low cohesion.
These classes appear to have high cohesion. These classes appear to have weak validation. These classes appear to have strong validation. These classes appear to have weak encapsulation. These classes appear to have strong encapsulation. Not all of the assert statements use assertions appropriately.
Given that the working directory is bigApp, and the following directory structure: bigApp -- classes -- com -- wickedlysmart -- source -- com -- wickedlysmart -- BigAppClass2. Invocation I will compile the file and place the. Invocation II will compile the file and place the. Invocation III will compile the file and place the. The code runs without exception. Given that Integer. An uncaught exception is thrown with no other output. Given the proper imports and given: Glanks have a Bostron.
Jookers implement Protefors. Glanks implement Bostrons. Jookers have a String. Bostrons implement Vonks. Bostrons have a Bostron. Given that the root directory contains a subdirectory called "office" that contains some files for a Java application, if "X" and "Y" are unknown arguments, and the following command is invoked from the root directory in order to create a jar file containing the office directory: jar -cf X Y Which are true?
X should be the file name of the jar file, and Y should be "office". X should be "office", and Y should be the file name of the jar file. Specifying a file name of the jar file here is optional. If a file name is not specified here, a file named office.
The file name, if specified, must be ended with. Given a partial API: Final class Items implements no interfaces and has one constructor: Items String name, int value And given that you want to make collections of Items objects and sort them using classes and interfaces in java.
E innerE; 3. Compilation fails regardless of which return is inserted. Given the following method signatures from ArrayList: boolean add E e protected void removeRange int fromIndexInclusive, int toIndexExclusive int size and given: 2. The program could deadlock. The output could be 5 4 3 2 1 D. The program could produce thousands of characters of output.
If the sleep invocations were removed the chances of deadlock would decrease. If the view method was not synchronized the chances of deadlock would decrease. C, G Drag and Drop 4.
B, E, F D, E, F A, D B, E Drag and Drop B and E B, C, E C, F A, D, F B, D, E A, C, F A, C Remember, the sleep method is static and operates on whichever thread is the currently running thread.
Work these nested if statements from the inside out. The innermost "if" block is lines 9— The next set is lines 8 and 12, and finally lines 7 and Given that, the first "if" is true, so the second "if" is evaluated. Since the second "if" test is false, its associated "else" line 12 is executed. The rest of the code is legal. Use the fragments below to fill in the blanks so that the code will compile, and when invoked with: java Dropkick fish will produce the output: "1 4 " Note: All of the blanks must be filled, not all the fragments will be used, and fragments can be used only once.
E is just correct. C and D are incorrect because no such rules exist. All of the overrides and overloads are legal. Overridden methods have stricter requirements, but lines 7—10 are overloaded methods.
Given that, it might appear that equals has been overridden, but in practice this overridden equals method performs exactly as the default method performs.
Therefore, the equals and hashCode methods will support their contracts, although it will be hard for a programmer to use this class for keys in a Map. D is incorrect based on the above. The setCity method includes argument validation, which is a good thing.
C, D, and E are incorrect based on the above. C and E are invalid syntax. D passes the assert test. When defining multiple variables in a for loop, line 5 uses the correct syntax.
Line 13 Answer for Objective 5. A and F are valid overloads of Big. E is incorrect because the PriorityQueue class itself provides no non-destructive traversal methods. F is incorrect because Lists are much better than Sets at index-based retrieval. Note that the current directory and its contents are not included. Line 8 attempts to assign a one-dimensional array into an int.
With "while" loops, the body only executes if the expression is true. With "do" loops, the body executes first, before the expression is evaluated. The final loop is a legal "for each" loop. In do2 , the compiler knows that "s" can contain only Integers and that st is a String.
If this line of code is removed, the parseInt invocation will throw a NumberFormatException when it is passed "a". E would be correct if the invocation on line 5 was either handled or declared. The variable in the same class is used. Also, even though the default comes before case "z", when the switch variable equals "z" the switch will skip the default and choose case "z".
The values method does NOT guarantee any ordering. Threads can be constructed with a name. Line 5 is declaring a Beach array and assigning three Beach-ish objects to it. Of course, you need to import some stuff for this program to compile.
With the proper import statements in place, A would be correct. The static inner class is legal, and on the real exam expect to find inner classes sprinkled throughout questions that are focused on other objectives.
Thistle can already access s. If Weed. In order for Weed. The three invocations will return: I. The other thread will wait until the lock is released and both threads will continue to normal completion. This invocation will run without error. E, F, and G are incorrect. Each will throw an AssertionError. As it stands, it makes the Employee class have low cohesion.
E is probably correct because the findEmployeesByState method should probably be placed in the Employee class. The syntax on line 10 is invalid and will not compile. If the syntax on line 10 was fixed, then option C would be correct. Remembering that PriorityQueues are sorted, the poll method removes the first element in the queue and returns it. The peek method returns the first element from the queue but does NOT remove it. Option D is incorrect based on the above.
The first time doStuff is invoked, the NFE is handled in main ; the second time it is not handled. Each class that implements Comparator will implement a compare method. The int primitive associated with each Stuff object is not an object. Note: Even if equals was overridden, six objects would be eligible. The duplicate Stuff object, while not in the Set, would still be eligible.
If doStuff was non-static, A and D would be correct. The output could be: 5 4 3 2 1 D. Table offers a rough guide to where you are in your studies. If you got less than 45 questions correct, the next chapter could be a big help. The following three suggestions are by far the most common: 1. Use a good study guide. Notice us not inserting a shameless plug here.
Take lots of practice exams. Just like in this book. Write lots of code. Code, Code, Code This chapter is about step number 3: writing lots of code. Of course, not all code is equally good as a study aid. What we DO mean is that you should write lots of small programs. On the real exam, most of the questions contain less than 13 lines of code. But while we were creating the questions for this book, we seldom wrote a program longer than 30 lines.
As you develop and test the code, you might discover that you should have had a different intermediate goal Go with the flow. In general, you want your goals to be as focused as possible. At the same time, you want your goal to test something interesting. Try it. Perhaps make a new flashcard about the thing you needed to look up.
The idea is to not get hung up trying to remember some little factoid. Again, use moderation. You want to understand what causes compiler errors, what throws exceptions, and so on. Instead of deleting the code that breaks, keep it inline and comment it out. And, of course, erroneous code can be a great topic for a flashcard. But, unlike on the job, you also want to test your knowledge and learn stuff.
When the code does something unexpected, study it for a bit before rushing in and adding a bunch of println s. Books by Kathy Sierra. Technical support and user instruction were both unavailable. Jan 24, Atendra rated it it was amazing. Just a moment while we sign you in to your Goodreads account. Eduardo rated kathyy it was amazing May 27, Ray Tan rated it really liked it Apr 25, Goodreads helps you keep track of books you want to read.
Click here to check if anything new just came in. A readme file clearly explained the installation process, which was a nice feature. Dec 31, Shruti Sabusuresh rated it really liked it. This book is a must for anyone programming in Java — not just for clearing the exam. The second part describes the working of different classes available such as Collections API, Generics, Exceptions and the n I have had a couple of years of experience in Java before I started lathy this book.
The changes appeared to implement well during testing, which added some flexibility to the native program. This website uses cookies to improve your experience while you navigate through the website.
Out of these cookies, the cookies that are categorized as necessary are stored on your browser as they are as essential for the working of basic functionalities of the website. Work fast with our official CLI. Learn more. If nothing happens, download GitHub Desktop and try again. If nothing happens, download Xcode and try again.
There was a problem preparing your codespace, please try again. Skip to content. Branches Tags. Could not load branches. Could not load tags. Go back. Launching Xcode If nothing happens, download Xcode and try again. Launching Visual Studio Code Your codespace will open once ready, ocp java 8 kathy sierra pdf download.
0コメント