100% Real Oracle 1z0-851 Exam Questions & Answers, Accurate & Verified By IT Experts
Instant Download, Free Fast Updates, 99.6% Pass Rate
Oracle 1z0-851 Practice Test Questions in VCE Format
File | Votes | Size | Date |
---|---|---|---|
File Oracle.Actual-Exams.1z0-851.v2014-06-19.by.Susan.215q.vce |
Votes 6 |
Size 1.46 MB |
Date Jun 19, 2014 |
File Oracle.Exactexams.1z0-851.v2013-11-27.by.SomeBody.260q.vce |
Votes 33 |
Size 1.87 MB |
Date Nov 27, 2013 |
Oracle 1z0-851 Practice Test Questions, Exam Dumps
Oracle 1z0-851 (Java SE 6 Programmer Certified Professional) exam dumps vce, practice test questions, study guide & video training course to study and pass quickly and easily. Oracle 1z0-851 Java SE 6 Programmer Certified Professional exam dumps & practice test questions and answers. You need avanset vce exam simulator in order to study the Oracle 1z0-851 certification exam dumps & Oracle 1z0-851 practice test questions in vce format.
The Oracle Certified Professional, Java SE 6 Programmer certification, achieved by passing the 1z0-851 Exam, represents a significant milestone in a Java developer's career. This certification validates a deep understanding of the core Java language and its fundamental APIs. It demonstrates proficiency in object-oriented programming principles and the ability to write robust, well-structured Java code. For employers, it serves as a reliable benchmark of a candidate's skills, often distinguishing them in a competitive job market. Preparing for the 1z0-851 Exam is not just about memorization; it is about cultivating a thorough comprehension of Java's architecture and syntax.
This series of articles is designed to guide you through the key objectives of the 1z0-851 Exam. We will break down complex topics into manageable sections, providing the detailed knowledge required to approach the exam with confidence. The journey to certification requires dedication and a structured study plan. This guide provides that structure, starting with the absolute fundamentals of the Java language, such as declarations and flow control, before moving on to more advanced concepts in subsequent parts. Success in the 1z0-851 Exam is a testament to your expertise as a professional Java programmer.
A core component of the 1z0-851 Exam involves a thorough understanding of how variables are declared, initialized, and where they are accessible within a program. Java is a statically-typed language, meaning every variable must have a declared type before it can be used. This includes primitive types like int, double, and boolean, as well as object reference types like String or any custom class. The exam will test your knowledge of the rules governing these declarations, including valid and invalid identifier names and the proper syntax for single and multi-variable declarations on one line.
Initialization is the process of assigning an initial value to a variable. The 1z0-851 Exam places heavy emphasis on the rules of initialization for different types of variables. Instance variables, which belong to an object, are given default values (zero for numbers, false for booleans, and null for objects) if not explicitly initialized. However, local variables, which are declared within a method, have no default value. The compiler will generate an error if you attempt to use a local variable before it has been explicitly assigned a value, a common trick question in the exam.
Scoping determines the region of code where a variable can be accessed. A variable's scope is defined by where it is declared. Instance variables are in scope for the entire lifetime of the object and can be accessed by any non-static method within the class. Static variables, belonging to the class itself, are accessible from any static or non-static method. Local variables are only in scope from the point of their declaration to the end of the block, typically a method or a loop, in which they were declared. Understanding these scope boundaries is critical for passing the 1z0-851 Exam.
The exam often presents scenarios involving variable shadowing. This occurs when a local variable has the same name as an instance variable. Within the local scope, the local variable takes precedence, or "shadows," the instance variable. To access the shadowed instance variable, you must use the this keyword, for example, this.variableName. The 1z0-851 Exam will test your ability to read code and determine which variable is being accessed in such situations. Grasping this concept is essential for correctly interpreting code snippets and predicting their output accurately.
Finally, the use of wrapper classes and the concepts of autoboxing and unboxing are crucial for the 1z0-851 Exam. Every primitive type in Java has a corresponding wrapper class, such as Integer for int or Double for double. Autoboxing is the automatic conversion that the Java compiler makes between primitive types and their corresponding object wrapper classes. For example, Integer i = 100; is an example of autoboxing. Unboxing is the reverse process, converting an object of a wrapper type to its corresponding primitive value. Understanding when and how these conversions happen is vital.
Mastering flow control is non-negotiable for success in the 1z0-851 Exam. These constructs direct the execution path of your program. The most basic is the if-then-else statement, which executes a block of code based on the evaluation of a boolean expression. The exam will test your knowledge of its structure, including nested if statements and the proper use of curly braces. A common pitfall tested is the "dangling else" problem, where an else clause can be misinterpreted by the compiler if braces are omitted in nested if structures. You must be able to trace the logic precisely.
The switch statement provides a clean way to handle multiple execution paths based on the value of an integer, enum, or string (in later Java versions). For the 1z0-851 Exam, which focuses on Java 6, you need to know that switch works with byte, short, char, and int, as well as their wrapper types and enums. A key concept tested is "fall-through." Without a break statement, execution will continue into the next case block. The exam will present code snippets that deliberately use or omit break to test your understanding of this behavior and its impact on the final output.
Looping constructs, including for, while, and do-while, are fundamental topics. The traditional for loop consists of an initialization, a termination condition, and an increment or update expression. The enhanced for loop, also known as the for-each loop, provides a simpler syntax for iterating over arrays or collections. The 1z0-851 Exam requires you to know the syntax and appropriate use case for each. The while loop continues as long as its condition is true, checking the condition before execution, while the do-while loop executes the body once before checking the condition.
Branching statements like break, continue, and return alter the normal flow of control. The break statement is used to terminate a loop or switch statement immediately. The continue statement skips the current iteration of a loop and proceeds to the next one. The return statement is used to exit a method, optionally returning a value. The 1z0-851 Exam often combines these with labeled statements. A labeled break or continue can exit or skip to an outer loop in a nested loop structure, a feature that requires careful analysis in exam questions.
A significant portion of the 1z0-851 Exam is dedicated to your knowledge of the core Java Application Programming Interface (API), particularly the classes within the java.lang package. Since this package is automatically imported into every Java source file, its classes are fundamental. The Object class is the root of the class hierarchy, and you must be familiar with its methods, especially equals(), hashCode(), and toString(). The exam will test your understanding of the contract between equals() and hashCode() and the consequences of overriding one without the other.
The String class is one of the most important classes to master for the 1z0-851 Exam. You must understand that String objects are immutable in Java. This means that once a String object is created, its value cannot be changed. Any method that appears to modify a string, like concat() or substring(), actually returns a new String object with the modified content. The exam will test this concept through code snippets that manipulate strings, requiring you to track which object a reference variable is pointing to after each operation. Familiarity with methods like length(), charAt(), and indexOf() is also essential.
While String is immutable, StringBuilder (and its thread-safe counterpart, StringBuffer) provides a mutable sequence of characters. For situations requiring frequent modifications to character sequences, using StringBuilder is far more efficient than creating new String objects repeatedly. The 1z0-851 Exam will expect you to know when to use StringBuilder over String. You should be proficient with its key methods, such as append(), insert(), delete(), and reverse(). Understanding the difference in performance and memory usage between these two classes is crucial for answering related questions correctly.
The Math class provides a collection of static methods for performing basic numeric operations. You do not need to memorize every method, but you should be familiar with the most common ones. These include abs() for absolute value, ceil() for rounding up, floor() for rounding down, and round() for standard rounding. The random() method, which returns a double value between 0.0 and 1.0, is also frequently tested. The 1z0-851 Exam questions might require you to use these methods to calculate a result or identify the correct output of a given expression involving Math class functions.
Concurrency is the ability of a program to execute multiple tasks or processes simultaneously. The 1z0-851 Exam introduces the fundamental concepts of multithreading in Java. The most basic way to create a thread is by either extending the Thread class and overriding its run() method or by implementing the Runnable interface and passing an instance of it to a Thread's constructor. The exam will test your knowledge of both approaches and their differences. Implementing Runnable is generally preferred as it allows the class to extend another class, avoiding the limitations of single inheritance in Java.
Once a Thread object is created, its execution does not begin until its start() method is called. This is a critical point tested in the 1z0-851 Exam. Calling run() directly will simply execute the code in the current thread, not in a new one. The start() method, on the other hand, registers the thread with the thread scheduler, which then calls the run() method in a new, separate thread of execution. You must be able to distinguish between the effects of calling start() versus calling run() on a Thread object.
A thread can exist in various states throughout its lifecycle, such as new, runnable, blocked, waiting, or terminated. While a deep understanding of the thread scheduler is not required, the 1z0-851 Exam expects you to know the basic state transitions. For example, a thread enters the runnable state after start() is called. It can be moved to a blocked state if it is waiting for an I/O operation to complete or a lock to be released. Methods like sleep() can temporarily pause a thread, moving it into a waiting state for a specified duration.
Synchronization is a key concept in concurrency, used to control access to shared resources by multiple threads. The 1z0-851 Exam touches upon the basics of synchronization using the synchronized keyword. When a method is declared as synchronized, a thread must acquire the object's intrinsic lock before it can execute the method. This ensures that only one thread can execute a synchronized method on a given object at a time, preventing race conditions and data corruption. You should understand how to apply the synchronized modifier to methods and code blocks to protect shared data.
The 1z0-851 Exam is, at its heart, a test of your understanding of object-oriented (OO) programming principles. Encapsulation is the practice of bundling data (instance variables) and the methods that operate on that data within a single unit, or class. It often involves making instance variables private and providing public getter and setter methods to control access. This protects the object's internal state from outside interference and misuse. Exam questions will require you to identify well-encapsulated code and understand the role of access modifiers (private, protected, public, and default).
Inheritance is another cornerstone of OO programming, allowing a new class (subclass) to inherit fields and methods from an existing class (superclass). This promotes code reuse and establishes an "is-a" relationship, where the subclass is a more specific type of the superclass. You must be proficient with the extends keyword and understand how constructors work in an inheritance hierarchy. The 1z0-851 Exam will test your knowledge of constructor chaining using super() to call a superclass constructor, which must be the first statement in a subclass constructor.
Polymorphism, which means "many forms," allows a reference variable of a superclass type to refer to an object of a subclass type. This enables you to write more generic and flexible code. The actual method that gets executed at runtime is determined by the object's type, not the reference's type. This is known as method overriding. The 1z0-851 Exam will present complex scenarios involving overriding, requiring you to know the rules for valid overrides, such as having the same signature and a compatible return type. You must also understand method overloading, which involves having multiple methods with the same name but different parameter lists within the same class.
Casting is the process of converting a reference from one type to another within an inheritance hierarchy. Upcasting, or casting a subclass reference to a superclass reference, is always safe and happens implicitly. Downcasting, casting a superclass reference to a subclass reference, is risky and requires an explicit cast. It can fail at runtime with a ClassCastException if the object is not actually an instance of the target subclass. The instanceof operator is used to check the type of an object before attempting a downcast to prevent this exception. The 1z0-851 Exam will test your ability to identify legal and illegal casts.
The Java Collections Framework is a unified architecture for representing and manipulating collections of objects. The 1z0-851 Exam requires you to be familiar with the main interfaces of this framework: List, Set, and Map. A List is an ordered collection that allows duplicate elements. The most common implementations are ArrayList, which is backed by a dynamic array, and LinkedList, which is implemented as a doubly-linked list. You should know the performance characteristics of each; ArrayList is fast for random access, while LinkedList is fast for additions and removals from the beginning or end.
A Set is a collection that does not allow duplicate elements. HashSet, which stores its elements in a hash table, offers fast performance but does not guarantee any order. TreeSet, on the other hand, stores its elements in a sorted order. For an object to be stored in a TreeSet, it must either implement the Comparable interface or a Comparator must be provided at creation time. The 1z0-851 Exam will test your understanding of how Sets handle duplicates and the requirements for using a TreeSet.
A Map is an object that maps keys to values. It cannot contain duplicate keys; each key can map to at most one value. HashMap is an unordered map that provides fast key lookups, while TreeMap maintains its keys in a sorted order. Similar to TreeSet, TreeMap requires that its keys are comparable. You will need to know the basic methods for Map, such as put(key, value), get(key), and keySet(), for the 1z0-851 Exam.
Generics were a major addition in Java 5 and are a key topic in the 1z0-851 Exam. They provide compile-time type safety by allowing you to create classes, interfaces, and methods that operate on types as parameters. For example, instead of a raw ArrayList, you can declare ArrayList<String>. This tells the compiler that the list can only contain String objects, preventing you from accidentally adding an object of a different type. It also eliminates the need for explicit casting when retrieving elements from the collection, making the code cleaner and less error-prone.
Polymorphism is a fundamental object-oriented principle that is heavily tested on the 1z0-851 Exam. It allows an object to take on many forms, meaning a superclass reference can be used to refer to a subclass object. The power of this concept is realized at runtime, where the Java Virtual Machine (JVM) determines which method to execute based on the actual object's type, not the reference variable's type. This mechanism, known as dynamic method dispatch or late binding, is central to creating flexible and extensible applications. You must be able to trace code and predict method calls in a complex inheritance hierarchy.
Method overriding is the practical application of polymorphism. When a subclass provides a specific implementation for a method that is already defined in its superclass, it is said to have overridden the method. The 1z0-851 Exam requires you to know the strict rules for a valid override. The method in the subclass must have the same name, and the same number and type of parameters as the method in the superclass. The access level of the overriding method must be the same or more accessible (e.g., a protected method can be overridden as public, but not as private).
The return type of an overriding method must also be compatible. This is known as covariant returns. For Java versions relevant to the 1z0-851 Exam, the overriding method's return type must be the same as, or a subtype of, the return type in the superclass. For example, if a superclass method returns an Object, the overriding method in the subclass can return a String, because String is a subtype of Object. Exam questions will often present code with subtle violations of these rules, asking you to identify compiler errors.
You must also understand what cannot be overridden. final methods cannot be overridden by subclasses. static methods cannot be overridden either; they can only be hidden. If a subclass defines a static method with the same signature as a static method in its superclass, the method that gets called depends on the type of the reference, not the object. This is a crucial distinction from instance method overriding and a frequent source of confusion. The 1z0-851 Exam will test your ability to differentiate between method hiding (for static methods) and method overriding (for instance methods).
Enums, or enumerated types, were introduced in Java 5 and are an important topic for the 1z0-851 Exam. An enum is a special type that represents a fixed set of constants. They are much more powerful and type-safe than the traditional integer constants or string constants they replace. Behind the scenes, an enum is a special kind of class, and each enum constant is a public static final instance of that class. This means enums can have constructors, instance variables, and methods, just like a regular class.
The constructor of an enum must be private or package-private. It is called once for each constant declared in the enum type. You can define instance variables within the enum to associate data with each constant. For example, an enum for planets could have instance variables for mass and radius. The 1z0-851 Exam will expect you to be able to write and interpret enums that have constructors and methods. You need to understand the syntax for declaring constants and passing arguments to their constructors.
Every enum implicitly extends the java.lang.Enum class. Because of this, an enum cannot extend any other class. However, an enum can implement one or more interfaces. The Enum class provides several useful methods, such as values(), which returns an array of all the enum constants in the order they are declared, and valueOf(String name), which returns the enum constant with the specified name. The 1z0-851 Exam will test your familiarity with these built-in methods and how to use them to iterate over or look up enum constants.
Enums can be used effectively in switch statements. When you use an enum in a switch, you do not need to prefix the constants with the enum type name in the case labels. This makes the code more readable. The 1z0-851 Exam often presents code snippets involving enums within switch statements or loops. You should be comfortable with the syntax and be able to predict the output of such code. Understanding the power and flexibility of enums is key to demonstrating your proficiency with modern Java features.
Java allows you to define a class within another class. These are called nested classes, and they come in four main flavors, all of which are testable on the 1z0-851 Exam. The first type is a static nested class. It is essentially a static member of the outer class. It does not have access to the instance variables and methods of the outer class object, only its static members. You can instantiate a static nested class without creating an instance of the outer class, using the syntax OuterClass.StaticNestedClass nestedObject = new OuterClass.StaticNestedClass();.
The second type is a member inner class. This is a non-static nested class, also known as an inner class. Each instance of a member inner class is implicitly associated with an instance of the outer class. Because of this association, it has full access to all members (both static and instance) of the outer class, including private members. To instantiate a member inner class, you first need an instance of the outer class, for example, OuterClass.InnerClass inner = outerObject.new InnerClass();. This syntax is a key detail for the 1z0-851 Exam.
The third type is a local inner class, which is declared inside a method. Its scope is limited to the method in which it is declared. A local inner class can access the members of the enclosing class, just like a member inner class. Additionally, it can access local variables of the method, but only if they are final or effectively final. This restriction is necessary because the inner class object might live on long after the method has finished executing and its local variables have gone out of scope.
The final type is an anonymous inner class. This is a local inner class that does not have a name. It is declared and instantiated in a single expression. Anonymous inner classes are typically used when you need to create a one-off implementation of an interface or an extension of a class, often for event handlers or Runnable tasks. The syntax is concise but can be confusing. The 1z0-851 Exam will test your ability to read and understand code that uses anonymous inner classes, particularly their scope and access rules.
The 1z0-851 Exam goes beyond basic flow control by testing your knowledge of assertions and exception handling. Assertions are a development tool used to check for conditions that should always be true. They are declared using the assert keyword followed by a boolean expression. If the expression evaluates to false, an AssertionError is thrown. Assertions are disabled by default and must be enabled at runtime using the -ea flag. The exam will test your understanding of the syntax and the fact that the code inside an assertion might not execute, which can have side effects.
Exception handling is a critical mechanism for dealing with runtime errors in a controlled manner. The try-catch-finally block is the core construct. Code that might throw an exception is placed in the try block. One or more catch blocks can follow to handle specific types of exceptions. The finally block is optional, but if present, its code is always executed, whether an exception was thrown or not. This makes it ideal for cleanup tasks like closing files or database connections. The 1z0-851 Exam will test your knowledge of the execution flow in various scenarios.
Java's exception hierarchy is important. All exceptions descend from the Throwable class. The two main branches are Error and Exception. Errors represent serious problems that applications should not try to catch, like OutOfMemoryError. Exceptions represent conditions that an application might want to catch. These are further divided into checked exceptions and unchecked exceptions (also known as runtime exceptions). Checked exceptions must be handled or declared, whereas unchecked exceptions (subclasses of RuntimeException) do not have this requirement. The 1z0-851 Exam will require you to identify which exceptions are checked and which are unchecked.
You must be able to create and throw your own custom exceptions. This is done by creating a class that extends an existing exception class, usually Exception or RuntimeException. You can then throw an instance of your custom exception using the throw keyword. Methods that can throw checked exceptions must declare them using the throws keyword in the method signature. The 1z0-851 Exam will test your ability to correctly write method signatures that declare exceptions and to write code that properly catches or propagates them.
As discussed in Part 1, the immutability of the String class is a crucial concept for the 1z0-851 Exam. Any manipulation of a String results in a new String object being created in memory. This can be inefficient if many modifications are needed. The exam will test this by presenting code that performs string concatenation in a loop. Using the + operator inside a loop to build a string is highly inefficient because it creates a new String and StringBuilder object for each iteration. Recognizing this performance pitfall is a key skill.
The StringBuilder class is designed for efficient string manipulation. Since it is mutable, methods like append(), insert(), and delete() modify the existing StringBuilder object directly without creating new objects for each change. This results in significantly better performance and lower memory consumption, especially when dealing with a large number of modifications. The 1z0-851 Exam will expect you to know when StringBuilder is the appropriate choice over String. You should be proficient with its API to predict the final state of a StringBuilder after a series of method calls.
A key difference between String and StringBuilder is their use of memory and how they are compared. Strings created as literals are often pooled by the JVM to save memory. Using the == operator on strings compares their memory addresses, not their content. To compare the content of two strings, you must use the equals() method. For StringBuilder, the equals() method is not overridden and behaves like ==, comparing references. This is a common trap on the 1z0-851 Exam. To compare the content of two StringBuilder objects, you must first convert them to Strings using the toString() method.
The 1z0-851 Exam will test your knowledge of various methods in both classes. For String, be familiar with substring(), indexOf(), lastIndexOf(), trim(), replace(), and split(). For StringBuilder, understand append(), insert(), delete(), deleteCharAt(), reverse(), length(), and capacity(). The concept of capacity in StringBuilder, which is the amount of storage allocated, as opposed to its length (the number of characters it currently holds), is also a testable topic. Understanding these methods in detail will enable you to solve complex manipulation problems presented on the exam.
The 1z0-851 Exam covers the basics of input and output (I/O) in Java. A fundamental aspect of this is interacting with the console. The System class in java.lang provides three static stream objects: System.in, System.out, and System.err. System.out is a PrintStream used for standard output, and you are likely familiar with its print() and println() methods. System.err is also a PrintStream used for error messages. System.in is an InputStream used for standard input, typically from the keyboard.
Reading from System.in directly is challenging because it is a low-level byte stream. The 1z0-851 Exam expects you to know how to wrap System.in with other stream classes to make reading user input easier. For example, you can wrap it in an InputStreamReader to convert the byte stream into a character stream, and then wrap that in a BufferedReader to read text line by line using the readLine() method. While newer classes like Scanner simplify this process, the exam focuses on the foundational I/O classes in the java.io package.
Writing formatted output to the console is another important skill for the 1z0-851 Exam. The PrintStream and PrintWriter classes provide the printf() and format() methods (which are equivalent) for this purpose. These methods allow you to create formatted strings using format specifiers, similar to the printf function in C. You need to be familiar with the common format specifiers, such as %s for strings, %d for integers, %f for floating-point numbers, and %b for booleans. The exam may ask you to determine the output of a given printf statement with various flags and specifiers.
The Console class, introduced in Java 6, provides a more modern way to interact with the console, especially for reading passwords without echoing the characters. You can obtain a Console object using System.console(). However, this method may return null if the JVM is not associated with a character-based console (e.g., when running in an IDE). The 1z0-851 Exam may test your knowledge of methods like readLine() and readPassword() from the Console class and the need to check for a null return from System.console().
Serialization is the process of converting an object's state into a byte stream, which can then be saved to a file, sent over a network, or stored in a database. Deserialization is the reverse process of recreating the object from the byte stream. The 1z0-851 Exam requires a solid understanding of how to make a class serializable and the rules that govern the process. To make a class serializable, it must implement the java.io.Serializable marker interface. This interface has no methods; it simply signals to the JVM that the class can be serialized.
When an object is serialized, the serialization mechanism writes out the class of the object, the class signature, and the values of its non-transient and non-static fields. If an object contains references to other objects, those objects are serialized as well, creating a graph of objects. This is a key point for the 1z0-851 Exam. If any object in this graph is not serializable, a NotSerializableException will be thrown at runtime. You must be able to analyze a class structure and determine if an attempt to serialize an object will succeed.
You can control the serialization process using the transient and static keywords. static fields belong to the class, not the object, so they are never serialized. transient fields are instance fields that you want to exclude from the serialization process. When the object is deserialized, transient fields will be initialized to their default values (zero, false, or null). The 1z0-851 Exam will test your understanding of these keywords and their effect on the state of a deserialized object.
During deserialization, the constructor of the serialized class is not called. The object is recreated from the data in the byte stream. This has important implications, especially in an inheritance hierarchy. If a superclass in the hierarchy is not serializable, it must have a no-argument constructor. This constructor will be called during deserialization to initialize the state of the non-serializable superclass part of the object. This is a subtle but important rule that is often the basis for difficult questions on the 1z0-851 Exam.
While Part 1 introduced the basics of creating threads, the 1z0-851 Exam demands a deeper understanding of how threads interact and share data safely. The synchronized keyword is the primary mechanism for preventing thread interference and memory consistency errors. When a thread enters a synchronized method or block, it acquires a lock on the object (or class, for static methods). No other thread can enter a synchronized block on the same object until the lock is released. You must understand that the lock is per-object, not per-method.
The 1z0-851 Exam will test your ability to identify potential race conditions in code and use synchronization to fix them. A race condition occurs when multiple threads access and manipulate shared data concurrently, and the final outcome depends on the unpredictable timing of their execution. Using synchronized blocks to guard all access (both read and write) to shared variables ensures that these operations are atomic and visible to all threads, thus preventing data corruption. Exam questions will present unsynchronized code and ask you to predict its potentially incorrect behavior.
Beyond mutual exclusion, threads often need to coordinate their actions. The Object class provides the wait(), notify(), and notifyAll() methods for this purpose. These methods can only be called from within a synchronized block, as they require the calling thread to hold the object's lock. Calling wait() causes the current thread to release the lock and enter a waiting state. It will remain waiting until another thread calls notify() or notifyAll() on the same object. The 1z0-851 Exam requires you to understand this wait-notify mechanism for implementing producer-consumer patterns.
notify() wakes up a single waiting thread, while notifyAll() wakes up all threads waiting on that object's lock. The awakened thread(s) do not immediately resume execution; they must reacquire the object's lock before they can proceed. This is a crucial detail for the 1z0-851 Exam. Often, wait() is called inside a loop that checks a condition (while (condition) { wait(); }). This guards against spurious wakeups and ensures the condition the thread was waiting for is actually true before it proceeds.
A comprehensive knowledge of the Java Collections Framework is essential for the 1z0-851 Exam. You need to understand the hierarchy of the core interfaces: Collection, List, Set, Queue, and Map. The Collection interface is the root, defining basic operations like add(), remove(), and size(). The List, Set, and Queue interfaces extend Collection and add their own specific contracts. A List is ordered and allows duplicates, a Set is unordered and disallows duplicates, and a Queue typically orders elements in a FIFO (first-in, first-out) manner.
The 1z0-851 Exam will test your knowledge of the primary concrete implementations of these interfaces. For List, you must know ArrayList and LinkedList. ArrayList provides fast, index-based access, but adding or removing elements from the middle is slow. LinkedList excels at adding and removing elements from its ends but has slow index-based access. For Set, you need to know HashSet, LinkedHashSet, and TreeSet. HashSet offers the best performance but no ordering. LinkedHashSet maintains insertion order, and TreeSet maintains natural sorted order.
The Map interface is not a subtype of Collection but is considered part of the framework. It stores key-value pairs. The main implementations are HashMap, LinkedHashMap, and TreeMap. These correspond to the Set implementations in terms of performance and ordering. HashMap is unordered, LinkedHashMap maintains insertion order of keys, and TreeMap maintains the keys in their natural sorted order. The 1z0-851 Exam will present scenarios where you must choose the most appropriate collection type based on the requirements for ordering, uniqueness, and performance.
You must be familiar with the key methods of these collections. This includes methods for adding, removing, and retrieving elements. For List, methods like get(index) and add(index, element) are important. For Set, the add() method's return value (boolean) indicates if the element was new to the set. For Map, put(key, value), get(key), containsKey(), and keySet() are fundamental. The exam will test your ability to use these methods correctly and to predict the state of a collection after a series of operations.
The ability to sort collections is a key skill tested in the 1z0-851 Exam. Java provides two main interfaces for defining sorting logic: Comparable and Comparator. The Comparable interface is used to define the "natural order" for a class. If you want objects of your custom class to be sortable, your class should implement Comparable and provide an implementation for its single method, compareTo(). This method compares the current object (this) with another object of the same type and returns a negative integer, zero, or a positive integer if this object is less than, equal to, or greater than the specified object.
Collections like TreeSet and TreeMap rely on their elements being Comparable to maintain sorted order. Similarly, the Collections.sort() method can be used to sort a List of Comparable objects according to their natural order. The 1z0-851 Exam will require you to implement the compareTo() method correctly. A common mistake is to write a compareTo() method that is not consistent with the equals() method, which can lead to unexpected behavior in collections like TreeSet. The contract states that a.compareTo(b) == 0 should imply that a.equals(b) is true.
Sometimes, you need to sort objects in an order other than their natural order, or you may want to sort objects of a class that you cannot modify (and thus cannot make it implement Comparable). In these cases, you use the Comparator interface. A Comparator is an external object that encapsulates a sorting logic. It has a compare(o1, o2) method that works similarly to compareTo(). You can create multiple Comparator implementations to define different ways of sorting the same type of object.
The 1z0-851 Exam will test your ability to write a Comparator and use it. Overloaded versions of Collections.sort() and the constructors for TreeSet and TreeMap accept a Comparator object. This allows you to specify the sorting order at runtime. For example, you could have one Comparator to sort Employee objects by name and another to sort them by salary. Being able to distinguish between when to use Comparable versus Comparator is a crucial skill for the exam.
Generics are a central topic in the 1z0-851 Exam, and you need a solid grasp of how they work. The primary benefit of generics is providing stronger type checking at compile time. By using generic type parameters, you can design classes and methods that work with different types while ensuring type safety. For example, when you declare a List<String>, the compiler ensures that only String objects can be added to the list. This prevents runtime ClassCastException errors that were common with pre-generic code.
The 1z0-851 Exam will test your understanding of generic syntax. You need to be able to correctly declare and instantiate generic types, such as List<String> list = new ArrayList<String>();. In Java 6, you must specify the type parameter on both the left and right sides of the assignment. The diamond operator (<>), which allows for type inference on the right side, was introduced in Java 7 and is not part of the 1z0-851 Exam syllabus. Be careful with questions that might use newer syntax; they would be invalid in a Java 6 context.
You should also understand how to write your own generic classes and methods. A generic class is declared with a type parameter in angle brackets after the class name, like public class Box<T>. This type parameter T can then be used as a placeholder for a real type throughout the class definition. Similarly, a generic method declares a type parameter before its return type, like public static <E> void printArray(E[] inputArray). This allows the method to work with arrays of different types.
The concept of wildcards is an advanced but important part of generics for the 1z0-851 Exam. Wildcards, represented by a question mark (?), are used to create more flexible generic methods. An upper-bounded wildcard (? extends Type) means the unknown type is a subtype of Type, useful for read-only operations. A lower-bounded wildcard (? super Type) means the unknown type is a supertype of Type, useful for write operations. Unbounded wildcards (?) mean any type is acceptable. Understanding when to use these different types of wildcards is key to solving complex generic problems on the exam.
While List is often the most intuitive collection, the 1z0-851 Exam places equal emphasis on Map, Set, and Queue. You must understand the core contract of a Map, which is a collection of key-value pairs where keys must be unique. The put(key, value) method is used to add or update an entry. If you call put with a key that already exists, the old value is replaced, and the method returns the old value. The get(key) method retrieves a value, returning null if the key is not found.
The interaction between Map keys and the hashCode() and equals() methods is a critical topic for the 1z0-851 Exam. Implementations like HashMap use the key's hashCode() to determine where to store the entry. If multiple keys have the same hash code (a hash collision), equals() is then used to differentiate between them. Therefore, for a custom object to be used as a key in a HashMap, it is essential that it correctly overrides both hashCode() and equals(). Violating the contract between these two methods will cause the map to behave incorrectly.
The Set interface models the mathematical set abstraction: a collection with no duplicate elements. The add() method will only add an element if it is not already present in the set. Like Map keys, Set implementations such as HashSet rely on the hashCode() and equals() methods of their elements to check for duplicates. TreeSet uses the compareTo() method (from Comparable) or a Comparator instead. The 1z0-851 Exam will test your understanding of how uniqueness is enforced in these different Set implementations.
The Queue interface is designed for holding elements prior to processing. Besides the basic Collection operations, Queue provides additional insertion, extraction, and inspection operations. Implementations like LinkedList (which implements the Queue interface) typically order elements in a FIFO manner. The offer() method inserts an element, poll() retrieves and removes the head of the queue, and peek() retrieves but does not remove the head. The 1z0-851 Exam might ask you to trace the state of a queue after a series of these operations.
The java.io package is a cornerstone of Java's platform independence, providing a rich set of classes for handling input and output operations. For the 1z0-851 Exam, you must have a solid grasp of its fundamental concepts, particularly the distinction between byte streams and character streams. Byte streams, whose abstract parent classes are InputStream and OutputStream, are used for reading and writing binary data, such as image files or serialized objects. They handle data as a sequence of 8-bit bytes.
Character streams, with abstract parents Reader and Writer, are designed for reading and writing text data. They handle data as a sequence of 16-bit Unicode characters, automatically handling the conversion to and from the local character encoding. This makes them ideal for working with text files in an internationalized application. The 1z0-851 Exam will test your ability to choose the correct stream type for a given task. Using a byte stream to read a text file might work in some cases but is not portable and can lead to data corruption if the file contains non-ASCII characters.
The java.io package employs the Decorator design pattern extensively. This means you can wrap one stream with another to add functionality. For instance, you can wrap a FileInputStream (a basic byte stream for reading files) with a BufferedInputStream. The BufferedInputStream adds buffering capabilities, reading data from the file in larger chunks into an internal buffer. This significantly improves performance by reducing the number of expensive disk access operations. The 1z0-851 Exam requires you to understand how to chain these streams together to build powerful I/O pipelines.
The File class is another essential component of the java.io package. It represents a file or directory path in a platform-independent way. It is not used for reading or writing file content but for interacting with the file system itself. You can use the File class to create or delete files and directories, check for their existence, get their properties like size and last modified date, and list the contents of a directory. The 1z0-851 Exam will test your knowledge of these file system manipulation methods.
A deep understanding of the concrete stream classes is necessary for the 1z0-851 Exam. For reading files, FileInputStream is the fundamental byte stream, and FileReader is the basic character stream. FileReader is a convenience class that internally uses a FileInputStream wrapped in an InputStreamReader with the default platform encoding. For writing files, FileOutputStream and FileWriter are the corresponding output classes. You must know how to construct these objects, remembering that they can throw checked exceptions like FileNotFoundException, which must be handled.
To improve performance, it is almost always recommended to wrap these basic streams with buffered streams. BufferedInputStream and BufferedReader for input, and BufferedOutputStream and BufferedWriter for output. The BufferedReader class is particularly useful as it provides the readLine() method, which reads a full line of text at a time. This is much more convenient than reading character by character. The 1z0-851 Exam will present code snippets and expect you to know the purpose and benefit of using these decorator classes.
Properly closing streams is a critical aspect of I/O programming. If you fail to close a stream, you can leak file handles and other system resources. The standard way to ensure a stream is closed, as tested on the 1z0-851 Exam, is to use a finally block. The stream should be opened in the try block, and the close() method should be called in the finally block. This guarantees that close() is called even if an exception occurs during the read or write operations. You must also handle the potential IOException that the close() method itself can throw.
Another important pair of streams are DataInputStream and DataOutputStream. These decorators allow you to read and write Java primitive data types in a machine-independent way. For example, you can use writeInt() to write an integer and readInt() to read it back. This is useful for creating binary data files with a specific format. The 1z0-851 Exam may test your knowledge of these methods and the order in which data must be read back (it must match the order in which it was written).
Serialization is a powerful feature that allows you to persist the state of an object or transmit it across a network. The 1z0-851 Exam requires a detailed understanding of the mechanism, which revolves around the ObjectOutputStream and ObjectInputStream. To serialize an object, you wrap an underlying OutputStream (like a FileOutputStream) in an ObjectOutputStream and then call its writeObject() method. This converts the object and all objects it references into a byte stream.
For an object to be serialized, its class must implement the Serializable marker interface. If a class is serializable, all of its subclasses are also serializable by default. However, the inverse is not true. The 1z0-851 Exam will test you on inheritance rules. If you have a serializable subclass but its superclass is not, the instance variables of the superclass will not be serialized. When the subclass object is deserialized, the non-serializable superclass must have a no-argument constructor, which will be run to initialize the superclass's state.
You have control over the serialization process using the transient and static keywords. Fields marked as static belong to the class and are never part of an object's serialized state. Fields marked as transient are instance fields that are intentionally excluded from the serialization process. Upon deserialization, these fields are initialized to their default values (null, 0, or false). The 1z0-851 Exam will ask you to predict the state of an object after it has been deserialized, paying close attention to transient fields.
The serialVersionUID is a version number associated with each serializable class. It is used during deserialization to verify that the sender and receiver of a serialized object have loaded classes for that object that are compatible with respect to serialization. If the serialVersionUIDs do not match, a InvalidClassException is thrown. While the compiler can generate one automatically, it is considered a best practice to explicitly declare a private static final long serialVersionUID. The 1z0-851 Exam may touch upon the purpose of this ID.
Go to testing centre with ease on our mind when you use Oracle 1z0-851 vce exam dumps, practice test questions and answers. Oracle 1z0-851 Java SE 6 Programmer Certified Professional certification practice test questions and answers, study guide, exam dumps and video training course in vce format to help you study with ease. Prepare with confidence and study using Oracle 1z0-851 exam dumps & practice test questions and answers vce from ExamCollection.
Top Oracle Certification Exams
Site Search:
SPECIAL OFFER: GET 10% OFF
Pass your Exam with ExamCollection's PREMIUM files!
SPECIAL OFFER: GET 10% OFF
Use Discount Code:
MIN10OFF
A confirmation link was sent to your e-mail.
Please check your mailbox for a message from support@examcollection.com and follow the directions.
Download Free Demo of VCE Exam Simulator
Experience Avanset VCE Exam Simulator for yourself.
Simply submit your e-mail address below to get started with our interactive software demo of your free trial.