Java Building Blocks Java 8 Certification

Java Building Blocks is the first important chapter for When appearing for OCA (Oracle Certified Associate Exam 1Z0-808),  (or for Java 8 Certification). You must understand the Java Basics & Java Data Type fundamental. You would not only learn the fundamental of java building blocks but also some of the important aspect of hands-on java programming which many experience developer may not be aware of. It is very important to go through each tips and techniques described in this article.

Before we deep dive on Java building blocks, I would like to list down the topic which I am going to cover it here

Java Basics

  1. Define the variables scope
  2. Define the structure of Java classes
  3. Create executable Java applications with a main method
  4. Import other Java packages to make them accessible in your code
  5. Compare and contrast the features and components of Java such as platform independence, object orientation, encapsulation,

Working with Java Data Types

  1. Declare and initialise variables (including casting or primitive types)
  2. Differentiate between object reference variables and primitive variables
  3. Know how to read or write to object fields
  4. Explain an Object’s Life-cycle (creation, “deference by reassignment” and garbage collection)

Read the full java certification syllabus article by clicking here, also review building block practice test paper

Understanding the Java Class Structure

In Java programs, classes are the basic building blocks. When defining a class, we describe all the parts and characteristics of one of those building blocks. To use most classes, you have to create objects. An object is a run-time instance of a class in memory. All the various objects of all the different classes represent the state of your program.

Fields and Methods

Java classes have two primary elements: methods, often called functions or procedures in other languages, and fields, more generally known as variables. Together these are called the members of the class. Variables hold the state of the program, and methods operate on that state. If the change is important to remember, a variable stores that change.

The simplest Java class you can write looks like this:

public class Bird{

Java calls a word with special meaning a keyword. The public keyword on line 1 means the class can be used by other classes. The class keyword indicates you’re defining a class. Animal gives the name of the class. Granted, this isn’t a very interesting class, so add your first field:

public class Bird{
String name;
public string getName(){
return name;
public void setName(String newName){
name = newName;

On next line, it defines a variable named name. We also define the type of that variable to be a String. A String is a value that we can put text into, such as “this is a string”. String is also a class supplied with Java. On lines 3–5, you’ve defined your first method. A method is an operation that can be called. Again, public is used to signify that this method may be called from other classes. Next comes the return type—in this case, the method returns a String. On lines 6–8 is another method. This one has a special return type called void. void means that no value at all is returned. This method requires information be supplied to it from the calling method;
this information is called a parameter. setName has one parameter named newName, and it is of type String. This means the caller should pass in one String parameter and expect nothing to be returned. The full declaration of a method is called a method signature.


Another common part of the code is called a comment. Because comments aren’t executable code, you can place them anywhere. Comments make your code easier to read. You won’t see many comments on the exam—the exam creators are trying to make the code
difficult to read—but you’ll see them in this book as we explain the code. And we hope you use them in your own code. There are three types of comments in Java. The first is called a single-line comment:

// comment until end of line

A single-line comment begins with two slashes. Anything you type after that on the same line is ignored by the compiler. Next comes the multiple-line comment:

/* Multiple
* line comment

A multiple-line comment (also known as a multi-line comment) includes anything starting from the symbol /* until the symbol */. People often type an asterisk (*) at the beginning of each line of a multi-line comment to make it easier to read, but you don’t have
to. Finally, we have a Javadoc comment:

* Javadoc multiple-line comment
* @author Admin

This comment is similar to a multi-line comment except it starts with /**. This special syntax tells the Javadoc tool to pay attention to the comment. Javadoc comments have a specific structure that the Javadoc tool knows how to read. You won’t see a Javadoc comment on the exam—just remember it exists so you can read up on it online when you start writing programs for others to use.

Comments are closed.