The aim of this site is to learn and improve knowledge of the Java programming language, version 6 and give an insight into the Java Standard Edition 6 Programmer Certified Professional Exam (IZO-851), which when passed gives the Oracle Certified Professional, Java SE 6 Programmer certification. The site is divided into three sections covering the Java6 programming language, the certification and a case study.
Java is an object oriented programming language and computing platform that was first released by Sun Microsystems in early 1996 and has grown in popularity ever since. In this section of the site we cover the Java language from the ground up, introducing different aspects of the language as we work through the sections detailed below:
We start out by downloading a JDK and setting up our environment before beginning our journey into Java6. With the environment set up we introduce the code structure of a Java source file and look at syntax. After this we look at the primitive variables available in Java before discussing method scope. We then take an in-depth look at the symbols used for mathematical and logical manipulation that are recognized by the compiler and commonly known as operators. Every computer language has conditional branching and loop structures and Java is no exception. We finish off this section with a look at the conditional and loop statements available in Java6.
The main emphasis of the Beginning Java6 section of the site was an introduction to the basic building blocks required to write a Java program. This section is all about objects
and the classes used to construct them. We start by looking at a predefined data type, the
Array object. Investigation of this class will give us an insight into using objects and classes before we
start to create our own. After this we examine class structure and the syntax required for class construction, before investigating reference variables and how to use them in Java. We have used methods throughout the lessons
so far, and the next lesson in the section goes into these members in much more detail. We then look at instance variables and their scope before studying constructors which are used to instantiate our objects. We finish the
section by taking an in-depth look at static members, followed by a new feature in Java6, enumerations.
Up until now, for learning purposes, we have ignored many important object oriented concepts that we can use within our Java programs. This neglect is rectified in this section where we start our study of OO concepts by
looking at encapsulation and how to protect our data. We then tackle inheritance over two lessons where we look at creating hierarchies, overriding methods and the use of
super. After this we look at
abstraction and how we apply it to our classes and methods. We then examine polymorphism and how to use it with our methods, arguments and return types. Our investigation of polymorphism continues as we investigate interfaces
and their usage. We then return to the idea of encapsulation as we look into nested classes, what they are and how to use them. We finish the section with a detailed look at the
Object class and the methods
we inherit and can override in our subclasses.
In this section we finish our studies on flow control by studying exceptions and assertions. Firstly we look at Java exceptions where we make a thorough investigation of the exception hierarchy and how Java's exception architecture hangs together. With an overview of exceptions under our belt we look at handling the various forms of exception in our code. After this we look at declaring and throwing exceptions in our code, which we can deal with straight away or allow to propagate up the stack to be dealt with elsewhere. We finish of our investigation of exceptions by creating our own bespoke checked and unchecked exceptions for when needed. With exceptions covered we turn our attention to the assertion mechanism available in Java. We learn appropriate uses of assertions and when not to use them. We also look at the runtime commands used to enable assertions, as and when required.
In our fifth section on learning Java6 we begin our investigations of the Java API by looking at the
StringBuffer classes. These predefined classes come
with a multitude of methods for working with strings and are part of the
java.lang package which is implicitly imported into all our Java programs for us. After this we broaden our horizon of Java
by investigating classes that are not implicitly imported into our programs. Before we look at other parts of the Java API however, we need to take a closer look at how Java stores predefined classes into namespaces,
which Java calls packages, and how we can import these packages into our programs. With knowledge of packages under our belt we can now look at parts of the Java API outside the default
package. Our first port of call is how we use I/O in Java and for this we will look at the
java.IO package. We start our exploration of Java I/O by looking at the class hierarchies involved
and then take an in-depth look at the byte stream classes and character stream classes used for this purpose. After this we look at the classes available for working with dates, numbers and
currencies. Most languages have an implementation of regular expressions and Java is no exception and we look at the classes used for pattern matching. We finish off our tour of the Java API
by looking at formatting and tokenizing our data.
In our sixth section on learning Java6 we look at multithreading and how to run parts of our program concurrently. We explain the terminology behind concurrency before looking in detail at running parts of
a program concurrently by subclassing the
Thread class and also by declaring a class that implements the
Runnable interface. Running separate threads
at the same time is great and we can certainly improve the performance of our programs using multithreading. But what happens when concurrent threads need to access and update some shared resource?
Java deals with this problem with synchronization and we investigate how we can control access to our code by synchronising at the method or block level. After this we investigate thread priorities and how
we can have the priority set automatically by the invoking thread or assign thread priorities ourselves using methods of the
Thread class. We finish our look at concurrency by
looking at how threads can interact with each other when they are within a synchronized method or code block.
In our seventh section on learning Java6 and our last section concerned with certification we look at collections and investigate generics. We start by defining what a collection is and look at some diagrams of
the collection types to get a feel for the various structures of the classes and interfaces involved. After this we make an in-depth investigation of generics and unravel the strange syntax we get with it.
Following on from this we examine the various hierarchies within The Collections Framework by taking a look at some concrete implementations of Sets, Lists, Maps and Queues. We than look at the
java.util.Collections classes that contain a lot of
static utility methods we can use with our collections. We finish the section by finding out how
to sort our collections using the
We start the section by looking at Graphical User Interface (GUI) concepts and the MVC paradigm and how this pattern can help in removing some of the complexity from the disparate parts of an application. We then introduce the Abstract Windowing Toolkit (AWT) and Swing libraries with an overview of those parts of these libraries we are interested in to create our own GUIs within java.
In Swing we store components within other components and we look at the
javax.swing.JFrame top-level container class, adding depth to frames using panes and the
background container class. Following on from this we take a look at several of the interactive Swing components available for use when creating our GUIs. Then we take a look at several layout managers
we can use to organise the components within our GUIs. We also need to make our GUIs interactive so what we require is a mechanism where we are alerted to a user event, such as a button being
clicked, and make a response to it. We look at how we an intercept user events and action them, which is known as event handling. We finish our lessons on Swing by looking at dialogs
which are windows that are displayed within the context of a parent window. Dialogs are often used to display some information, show messages to the user or prompt the user for input.
We finish the section by looking at Remote Method Invocation more commonly known as RMI and how we can use it to access methods remotely.
This section of the site covers the requirements for the Java Standard Edition 6 Programmer Certified Professional Exam (IZO-851) which when passed gives the Oracle Certified Professional, Java SE 6 Programmer certification.
In this section we look at all types of class declaration and extension and how to use interfaces and the package and import statements. We examine the declaration, initialization and usage of primitives, arrays, enums, and objects as static, instance, local variables and their respective scopes. After this we cover correct use of overriding and overloading of methods as well as identifying legal return values for methods. we investigate constructors to determine if a default constructor will be created, and if so, determine the behaviour of that constructor. We finish of this section by studying class instantiation and how to instantiate nested and non-nested classes.
In this section we look at the different syntax we can use to affect the flow of logic through our programs. We start by looking at code to implement if
switch statements whilst identifying legal argument types for them. We then investigate the different types of loops available in
Java and the iterators and their usage within a loop. We will also look at how we can break from a loop, continue from within a loop and label a loop to continue execution from. We continue our study of flow
control by looking at assertions and when, and when not, they should be used. We finish our certification lessons on flow control by looking at exceptions, handling exceptions and how to declare methods and
overriding methods that throw exceptions. We also need to understand what happens to our code when an error or any type of exception occurs in a code fragment and what happens when particular exceptions occur.
We start this section by looking at code that uses the primitive wrapper classes and/or autoboxing and unboxing. We then look at the differences between the String, StringBuilder, and StringBuffer classes. After this
we investigate how we can use classes with the
java.io package to read from files, write to files and use the
PrintWriter sometimes in unison to create a software solution. We then use classes from the
java.text package to correctly format or parse dates, numbers, and
currency values for a specific locale including usage of the appropriate methods to use the default locale or a specific locale. We finish the section by looking at regular expressions and examine how to format and tokenize our data using Java6.
This section is all about concurrency and we start it by looking at thread definition, instantiation and execution using the
java.lang.Runnable classes. After this we investigate the different
states in which a thread can exist, and identify ways in which a thread can transition from one state to another. We finish the section by examining Java's locking mechanisms at the class and object level and
how we can synchronize methods and blocks of code to protect static or instance variables from concurrent access problems.
We start this section by looking at encapsulation, its advantages and how to achieve it within our code. We then look at the design principles of coupling and cohesion and describe the benefits of loose coupling and high cohesion. We then explain polymorphism and how we use it in the Java language before looking at object reference casting and determine when casting will be necessary whilst recognizing compiler vs. runtime errors, related to it. After this we examine the effect of modifiers on inheritance with respect to constructors, instance or static variables, and instance or static methods. We then look at code that declares and/or invokes overridden or overloaded methods and code that declares and/or invokes superclass or overloaded constructors. We finish the section by investigating code that implements "is-a" and/or "has-a" relationships.
We start this section by looking at the various types of collections and their corresponding interfaces and which type of collection is suitable for specific types of data. We then look at usage of
the Comparable interface. After this we look at the
equals() method of the
Object class which only ever returns
true when the reference variables refer to the same object which
isn't helpful when we want our collections sorted and stored dependent upon fields in the collection. So in this lesson we look at correct and incorrect overrides of corresponding
hashCode() methods and explain the difference between
== and the
equals() method. Generics were introduced with Java6 and in this lesson we look at the reasons for doing
this. We then look at usage of type parameters in class/interface declarations, instance variables, method arguments, and return types. We finish the lesson by looking at generic methods as well as methods that
make use of wildcard types. We finish the section by looking at array and list manipulation using the
java.util package, usage of the
interfaces for sorting collections and the effect of natural ordering of primitive wrapper classes and
java.lang.String on sorting.
In our first lesson within this section we look at access modifiers and also investigate the package and import statements. We then look at the
javac command we use to compile our Java programs and
java command to run our programs. We finish the lesson with a look at JAR files and how to use them. After this we look at method parameters that are passed into methods as reference variables
and primitive variables and the effects that modification within the methods has on the variable type in question. We then examine the point at which an object becomes eligible for garbage collection, and determine
what is and is not guaranteed by the garbage collection system and how the behaviors of
System.gc and finalization impact this. In our final lesson within this section we look at the various operators that are
available in Java and how to use them.
In the final section of the site we do a non-trivial case study that reinforces what we have learnt in the other sections of the site. The case study will incorporate a GUI and several architectural patterns, such as MVC that was introduced in the Swing section of the Learn Java6 part of the site. Where a new pattern or concept occurs within the case study that isn't covered elsewhere on the site it will be discussed in situ, otherwise we will just link to the relevant lessons at the end of each case study lesson.
In this section of the case study we look at a project proposal and set up our environment. We start by looking at information gathered from the stake holder who we shall call 'Stocking Goods Limited' and how this can be translated into a multi tiered user application fit for purpose. With the basic requirements of the project proposal analysed we can build the file structure for our source and class files. We finish this section by writing code to create a Manufacturer test file to be used with the Case Study.
In this section of the case study we look at the model code for our project and code as much of the model as we can from the information provided within the Project Proposal. The stakeholder Stocking Goods Limited have supplied us with a
Stock interface that must be implemented and from this we can also derive some exception classes. In our first lesson of the section we code up the
Stock interface and exceptions for
our model code and compile them. The stakeholder has also requested that we create a class representing the record information within the Manufacturer file called unsurprisingly
they see a lot of future reuse of this file and it will also be helpful when implementing the
Stock interface. The final thing we can do with the model at present is implement the
interface and create some method stubs we will come back to when we revisit the model code in the Model Part 2 section.
In our first lesson of the section we spend some time thinking about the overall design of the GUI. This includes the common panel we are going to display to the user on startup for the entry of the Manufacturer file location/port, and how we are going to display the Manufacturer data to users whilst allowing options to search, stock and unstock. In our first lesson of the section we draw up some rough sketches for our panels, make some design decisions with regards to user interaction with the panels and name some classes needed to implement our design choices. We will begin coding the view part of the MVC pattern, starting with the classes that are independent of other classes within the Manufacturer application. We finish the section by compiling the code for the Manufacturer application startup and also the saved run mode / run mode options.
In this section of the case study we do the first part of our controller code by creating an exception class for our services and the
In this section of the case study we finish off the model code for the case study. To do this we will have to add some imports to the
StockImpl class and complete the method stubs we
left for this section of the case study. We will start by completing the
search() method and then finish the model code by completing the
In this section of the case study we complete our controller code by implementing the
Services interfaces. The
RemoteServices interface will provide remote access to and interaction
with the Manufacturer file from a remote client, whilst the
Services interface will provide local access to and interaction with the Manufacturer file from a local client.
In our final section on coding the case study we complete the view code elements. We start the section by coding the
RunModeDialog class which creates a dialog box to accept and
validate run mode options for the Manufacturer application. We then implement the code for when a user has entered the manufacturer application with a run mode of "server". We finish the section
and complete the coding for the Manufacturer application by coding the
ManufacturerWindow class and uncommenting the instantiations of the
ManufacturerWindow objects within the
In the final section of the Case Study we do some testing and wrap up the loose ends. We start by writing a program to test various methods of the
StockImpl class which will also test
Manufacturer class in the process. We will write out methods called to a log file and view the logged results, thus also testing that our logging is working as intended. After this
we write a test program to validate our locking is functioning correctly. For the view code we do some visual checks to ensure the GUI is working correctly. This will include starting up the
Manufacturer application in non-networked client, server and networked client modes as well as checking that the visual presentation of the manufacturer data file is displayed correctly using our
custom table model. In our final test for the case study we do some visual checks to ensure the controller code is working and end-to-end testing to show that the disparate parts of our system
function together correctly. We have been using
javadoc comments throughout the code we have written and we finsih the section by creating the
javadoc documentation for the
packages we have coded. We then wrap all our files up neatly in a
jar file so we can easily distribute them and to also reiterate usage of the