Java 8 Core Development - Prepare for OCJA OCJP

Full syllabus of a classroom-based Java core training and exam prep with theory, exercises and lab sections.
4.4 (41 ratings)
Instead of using a simple lifetime average, Udemy calculates a
course's star rating by considering a number of different factors
such as the number of ratings, the age of ratings, and the
likelihood of fraudulent ratings.
679 students enrolled
83% off
Take This Course
  • Lectures 163
  • Exercises 5 coding exercises
  • Length 20.5 hours
  • Skill Level All Levels
  • Languages English
  • Includes Coding Exercises New!
    Lifetime access
    30 day money back guarantee!
    Available on iOS and Android
    Certificate of Completion
Wishlisted Wishlist

How taking a course works


Find online courses made by experts from around the world.


Take your courses with you and learn anywhere, anytime.


Learn and practice real-world skills and achieve your goals.

About This Course

Published 10/2015 English

Course Description


Read the problem, write your code and get the feedback automatically. That's it!




This course is for those want to be a Java programmer by following a proven methodology and one-to-one online version of the lectures I gave to hundreds of students in several classrooms in several high-quality training center.

The biggest missing part for programming students is the exercises that they may work on. This class has high-quality exercises and their solutions right after the video explanations.

Here is our agenda:

0- Why java? What is platform independency? Why it is the most used programming language in professional software development?

1- Learn programming basics:

Using variables, primitive types, mathematical and logical operators.

Control structures, loops and really high-quality exercises to have hands-on experience.

2- Learn one dimensional and multidimensional arrays:

Use this basic data collection and use them inside real-world, fun practices. Find the longest lost series of an NBA team for instance :)

3- Learn object oriented programming:

Learn encapsulation, inheritance, abstraction with great examples and exercises. Possibly you wasted lots of time by watching similar unclear explanations so far. It is time to polish the dust of these concepts.

4- Learn core types and great utility classes of Java.

How a professional programmer leverages built-in types and utility classes in real life? StringBuilder, StringBuffer, Date type, String - Date conversions with SimpleDateFormat, Math class, Collections and Arrays class the topics you will learn.

5- Learn regular expressions.

Extracting useful data from a string by regular expressions is the greatest feature of all programming languages. But it is the most overlooked one. We don't overlook it. With two great explanation you will learn how to extract data from a URL and you will validate an email address ( by not Googling and copying of course!!!)

6- Learn data collections.

Everyone teaches you what is a list, set and map. How to put data and retrieve it. But this is the top of the iceberg. You MUST know where to use them, when to leverage the collections. Included exercises are asked in job interviews!!! Hold tight!!!

7- Learn file operations

How java communicates with files, read text files, binary files or write to them? How the content of the file is processed with data collections? You will learn by great exercises.

At this point you may move on Java EE course for further understanding.

8- Functional programming in Java 8

Using ASM interfaces, Function, Predicate, Consumer, Supplier interfaces, lambda expressions.

Using streams to process collections in functional style.

Leveraging multi-cpu cores easily by using parallel streams

Have a great experience!!!

What are the requirements?

  • Will to spend time on exercises
  • Will to spend time on theory of each topic
  • Basic computer skills

What am I going to get from this course?

  • Create a Java desktop application
  • Use even the smallest control structure in practical examples
  • Leverage the object oriented programming in best way
  • Use encapsulation to keep your data safe
  • Use encapsulation and abstraction for reusable module development
  • Using data collections professionally
  • Interacting with binary and text files
  • Create binary or text files after processing data
  • Create a user interface by using swing

Who is the target audience?

  • Even with no experience in programming
  • Programmers with even no experience in object oriented programming
  • Programmers that already know an object oriented programming language

What you get with this course?

Not for you? No problem.
30 day money back guarantee.

Forever yours.
Lifetime access.

Learn on the go.
Desktop, iOS and Android.

Get rewarded.
Certificate of completion.


Section 1: Course Introduction

The tools we will use will be explained.

Using the exercises and checking the solutions, source codes will be explained.


Java became popular by its platform independent architecture.

When you write an application for Windows, you may port it to Mac or any Linux distribution without any further effort. This is amazing.

You will learn how platform independency works.

All new students confuse what is JDK and JRE. JDK is used by only developers and contains development tools like compiler but JRE is used by anyone.

Introduction to Java
3 questions
Preparing development environment

Some basic syntax rules explained.

What is statement in Java?

How to separate statements?

How to define variables and assign values to variables?

How to allocate memory for an object with new keyword.

Section 2: Programming with Java 101

All the source files used throughout the course is here:


Creating variables and assigning values.

Running our very first application.


Throughout the course you will need to import some projects into the workspace of Eclipse. Thats why you need to learn how to import a project from external source and then export your own code.

Importing means: Using the pre-developed code in your very own development environment.

Exporting means: Packaging the source code of your application so that anyone else can use your code.


Primitives are the exceptions of object oriented Java. Apart from the objects, they don't have any methods, they can not be pass by address value etc. (May not make sense for now, just be familiar with the terms) They are simply used for storing some basic (primitive values).

Simple primitive values are: int, float, long, short, char, boolean.

1 page

You will do some mathematical operations on primitive variables.

Solution of exercise 1

int is the most known integer type in Java. In case you need to store much greater values, you need to use long type. Because its range is much more greater than int's.

If you will store tiny numbers (namely smaller than 256) you may use short type not to consume more memory.


According to the needs, you may use short, int and long types to represent integer values. In some cases you may need to use them together. In that case you should convert them properly.

Type casting means converting different types to each other and accepting possible data loses so that compiler does not complain about these possible data loses.

2 pages

You are given heterogenous type of variables in this exercise.

You need to cast the types for acquiring a single result with desired type. Good challenge!

Solution to exercise 2

We represent floating point numbers with float and double types.

Default floating point type is double and its range is so wide.

If you will store tinier floating point numbers, you may use float type.

In this case you should append "f" next to each floating point number. Otherwise they will be converted to double automatically.

2 pages
We have given an integer value as radius of circle. Find the perimeter of that circle by representing PI number with different floating point types.Pi number will be 22/7. We will have 3 Pi numbers. piInt will represent Pi number as int. => 3 piFloat will represent Pi number as Float. => 3.142857 piDouble will represent Pi Number as Double. => 3.142857142857143
Solution to exercise 3

Mathematical operations have precedence order by default. If you don't change the precedence order will be

1- Multiplication, division, modulus

2- Summation and subtraction

Group 1 and group 2 is executed from left to right among each other.

Exercise 4 - Applying operator precedence
1 page
Solution to exercise 4

You will learn

  • +=, -=, *=, /= and %= operators for quick arithmetic and assignment
  • ++ and -- operators for quick increment and decrement o f a value by 1

Processors run with boolean algebra. Everything is 0 or 1 or ( true or false)

In any software, you control the execution flow with true and false values also.

True and false values are represented with boolean type.

You will learn boolean types and boolean arithmetics.

2 pages

Boolean type is a truth-value and denoted by only one bit (0 or 1). In that case, an expression is either true or false. Sometimes we need to combine some values to yield a combined result. Combining operation is done with Boolean algebra. For instance;

“The customers subscribed in last three months who did not pay the bill this month” expression has two boolean values inside:

1. The customers who subscribed in last three months

2. The customers who did not pay the bill.

This expressions can be combined by an and operation: expr1 and not expr2 if 1. expr1: The customers who subscribed in last three months 2. expr2: The customers who did pay the bill. Boolean algebra operations are the conjunction and, the disjunction or, and the negation not. In java, AND operation is denoted by &&, OR operation || and NEGATION operation by ! .

Solution to Exercise 5

You may write a value into console with

System.out.print() and System.out.println() methods. You may pass any object instance into this method so that they can be represented as String (text).

print and println methods have a simple difference: println methods put a new line character at the end so that lines are broken.

Introduction to primitives
8 questions

We represent a single character with char type.

Char is an integer corresponding to its ASCII value in fact. So you can change a char variable's value such as an ordinary integer. This is called as char arithmetic:

Character and character arithmetic
2 questions
1 page

A char is an integer between 0 and 65535 implicitly. For instance the code below prints A.

char c = 65;


If you increment c by 1, this code will print B.

You will have an hands-on experience with character arithmetic now.

Solution to exercise 6 - Modifying char with arithmetic operations
Section 3: Control Structures and Loops

When we need to modify the flow according to a condition, we may use if statements. If a Boolean expression is true, we may do something, else something different. This can be visualized with a flow chart.

You will learn how to construct a flow chart and then implement them with if-else blocks.

1 page

We will develop an evaluating system for students.

Create a variable to store the exam result.

Our system will print the letter grade according to the

table below such as “Your grade is B for 56.” If the point smaller than 60, system will print “You

may re-attend the exam.”, otherwise “Thanks for attending the exam.”

If else blocks and operator Precedence
2 questions

Switch statement is the alternative to if-else blocks.

If else statements control the execution flow with boolean values. But switch statements control the execution flow with integer, string or enum values.


•Loops is used to do similar thing several times not to copy-paste code several times.

•Loops can be executed as long as a condition is true and can be stopped when this condition is not satisfied.

•Each execution of the same statement is called as “iteration”.


"while" loop is the alternative to for loop.

With while loop you only need to define the termination condition.

1 page

This exercise is a common and well-known exercise for every programming language:

Drawing some shapes with * character and combination of for loops.


In some specific cases you may need to end the execution of a for loop. In that case you use break statement.


Nested loops: Loop inside a loop

Nested loops are being used inside in most of the applications.

You can use a loop inside a loop or you may use them sequentially. Their boundaries might be completely independent from each other or their boundaries may change according to each other.

Nested Loops 2 - Dependent Boundaries
Exercise - Using nested loops
1 page
Solution to exercise
Exercise - Using nested loops 2
1 page
Section 4: Array
  • Array is a series of primitive variables or object instances.
  • Used for multiple values with the same type.
  • Stored in heap space.
  • Defined with this syntax:
  • type [];

•You may initialize the array upon the allocation of memory with this syntax:

•int x [] = new int[] {1,-1,9,0,5};

  • If x is the starting address of an array;
  • arr[0] => x
  • •arr[2] => skip 2 in items from the beginning of the array. 32 bits each.
  • So add 2*32 bits to the beginning address => go to x +64
  • Read size of int bytes from there. So read 4 bytes and get the value.
  • When you try to access a memory beyond of the array, you get this exception. Because the memory block you are trying to access is out of bounds of the array.

•We can use for and while loops to traverse a loop. Length of an array can be accessed by length attribute of array.

int myGreatArray[] = new int[10];

for(int i = 0; i < myGreatArray.length; i++){



Sum the even numbers in an array
1 question

All tabular data can be represented as arrays of arrays. They are called as multi-dimensional array.

Board games like chess, match-results table of a football league, sales data over months, seat plan of a bus...

Every row means a separate array.

Section 5: Class and Method
  • Object is anything abstract or concrete you can “define” with some attributes and/or behaviors. Eg:

Bicycle: Is an object with two tiers, paddles and a seat.

Human: Is an object with a torso, two legs, two arms, a head and speaking, thinking behaviors.

Love: Is an object between two human that can last forever or may end quickly.

  • Class is the package of some attributes (values related to an object) and some behaviours.
  • Instance is the real object with flesh and blood, allocating some memory to store its individual values.


For creating an instance in Java, "new" keyword is used. When you create an instance enough memory is allocated in JVM and starting address of the instance returns a reference.

  • Method is a program unit takes some arguments, process them and yield a single result.
  • Some common tasks are put into a method and can be used over and over again.
  • § If you define a return type, you must return a value of this type.

    § If return type is void, there is no need to return a value. If so, you can not return.

    § After returning a value, you can not execute any statement.

    § All flows execution must return a value.

    § You may return only one value.

  • 07:03
  • A method MUST be inside a class.
  • A method (mostly) MUST be invoked from an instance of a class.

  • 08:17

    Class is a meta-data (definition) of a real world object and the heart of object oriented programming. It is above all methods, behaviors contrary to functional programming or declarative programming. Thus, before coding some code flow, you need to design a class to store some state inside an object (instance). That is why no code may exist outside of a class. So does it make sense to put main method into a class? It should from now on. You can create a class with class keyword in a separate file and define some attributes and methods inside it. You can create concrete objects with new keyword. As soon as you create an instance and allocate some memory for it, you will be able to store state of this object. State is the snapshot of an object at current time and can be modified either directly or via methods indirectly. Both methods and attributes can be accessed by dot notation on any object. (instance)

    2 pages
    • Design and create a class.
    • Create an instance by new keyword.
    • Accessing / modifying attributes and methods of an instance.
    1 page

    A method mostly returns a value.

    (If return value is void, there is no need to return a value) return keyword completes the execution of the current method so that none of the below lines inside the method are executed.

    If the return type of the method is not void, than all of the execution flows must return a value.


    Methods with same name may exist in the same class if their argument lists are different.

    These methods are called as overloaded versions of each other.

    int sum(int v1, int v2)

    int sum(int v1, int v2, int v3)

    int sum(int v1, int v2, int v3, int v4)

    • If we need to process an unbound number of arguments with same type we may put them into an array and then pass to the method

    String concatanateStrings(String[] values);

    • We use variable arguments to pass any number of variables to a method without using an explicit array

    String concatanateStrings(String… values)


    Constructor is a special method that

    • has no return value
    • executed just after memory allocation for an instance is completed.
    • When you create a class with new keyword, constructor is called internally.

    Constructor eases to set instance variables without writing explicit lines to set them.

    Static context

    So far, we have dealt with readdressable (variable) values that created at run-time (while the execution of the program). They are called as «Dynamic variables» When you create a new instance of a class, a brand new memory is allocated in heap space. Instance context isolates different instance’s values and method executions from each other.

    Java has another context called «static».

    Static context: Before the execution of the program (on class loading phase), variables are stored into class space and the address does not change throughout the execution

    Section 6: Memory Management in Java
    When main method is executed, JVM asks for some memory from the OS and size of this space can not be changed during the program execution.

    Java application can not interfere with a memory block outside the JVM.

    JVM Memory Management
    3 questions

    Method execution order is done inside stack space.

    When a method is called, method-specific data is collected, tied together and put into stack space. It is removed when the execution is done.

    You will learn the details of stack space. If you know the stack space in theory, dealing with references and instances will be easier.


    Stack space is limited. Here, without popping a stack frame from the stack, a new one is pushed. So allocated memory for method information grows rapidly.

    JVM throws a StackOverflowException and halts the execution.


    Different references to the same object throughout the application refer to the very same memory address. In this case one of the references modifies the object, all other references will be aware of that modification.

    This is not valid for primitive values. Next lecture will demonstrate that fact.


    Since primitives are stored in stack instead of heap space, references from different method contexts will use the copy of the values. So modification of the value on a reference will not be reflected to other references.

    Section 7: Object Oriented Basics

    Object oriented programming means that any value or behaviour must be attached to a class that corresponds to an entity in real world.

    It is a professional approach in software programming supplies:




    An object instance may include any other object instances either with the same type or different type.

    This is called as composition.


    •Data encapsulation hides critical data of a class (entity) from other classes by preventing access with access modifiers.

    •Because some data is internal and critical data of an object.

    •The attributes might be in a specific range, specific proportion with each other or they should not be assigned some specific values to work properly.

    Other object oriented concepts
    Section 8: String Object and Regular Expressions

    String is used for storing texts in Java programs.

    String is composed of a character array implicitly and some utiliyt methods.


    String equality is done by equals() method.

    Never ever use == for comparing strings.

    Watch the lecture and see the details.


    String methods:

    length(): Returns how many characters inside

    charAt(): Returns the character at any index

    indexOf() : Searches for a character or string inside this string

    substring(): Returns the desired part of the string


    split(): Splits the method from a desired character and put the splitted strings into a String array

    replace(): Replace a word or character with a given string or character.

    toLowerCase(): Converts all the characters into lower case.

    toUpperCase(): Converts all the characters into upper case.

    contains(): Checks if a string exists in this string.

    1 page

    You will learn using overloaded versions of indexOf() method.

    indexOf() method in String has some overloaded versions to configure the index where to start. This is used to count words in a string. Search will be case sensitive. Method is: indexOf(int startIndex)

    1 page

    You will learn

    • Using overloaded versions of indexOf() method.
    • Using substring() method to extract words.
    1 page
    You will practice the methods in String class. ! indexOf, split, toUpperCase, toLowerCase.Strings have many methods to utilize text variables:

    indexOf(): finds another string in the current string

    split(): splits the string according to a given string and returns the parts as a string array

    toUpperCase(): converts all the letters inside a string to lowercase toLowerCase(): converts all the letters inside a string to uppercase.


    We construct some template with some special markers search for a string snippet that matched that template.

    •This special markers are called as regular expressions.

    •Regular expressions are used to

    •Determine if a string matches a given template (email address, URL)

    •All the substrings of this string matches a given template.

    Found result can be used to count the occurrences, replace them with another string.


    Two exercises will be done:

    1. You will use regular expressions to break a sentence from, one blank character, multiple blank character, a punctuation mark, a new line character.
    2. Write a regular expression to find all spots that does not start with a capital letter after a sentence is completed.


    Which ones below are real email address? Write a regular expression to decide if each one is a valid email address or not.















    Check if all the characters are lowercase alphabetic characters in a string
    1 question

    You will learn how to parse a url into its elements. For instance

    will be parsed to:


    protocol: https

    course url: java-8-core-training-

    internal url: learn/?instructorPreviewMode=student#/lecture/3699776

    Section 9: Most Used Built-in Classes

    Primitives are the exceptional type of an object oriented language.

    They need to be wrapped into a class in some cases to be used as objects.

    For converting a primitive to an object, we use wrapper classes. They are Integer, Float, Double, Character, Long, Short, Boolean

    • Boxing: To put a primitive value into corresponding class instance.
    • Auto-boxing: Java boxes the primitive value when it is assigned to a corresponding class reference.
    • Unboxing: Getting a primitive value from Integer, Short, Long, Float, Double, Character instances.

    java.util.Date: Simple class to represent a given time.

    Used for simple time comparisons and string-time conversions


    •Done with SimpleDateFormat class.

    •This class may convert a String to Date and vice versa.

    •Format is something like dd/MM/yyyy hh:mm:ss


    •Much more complex class than java.util.Date.

    •Have ability to manipulate date and time

    •Have ability to see so much detail of the date inside.

    •Have ability to change locale and timezone.


    How to convert

    • String to Date by using SimpleDateFormat
    • Date to String by using SimpleDateFormat
    • Date to Calendar
    • Calendar to Date

    Write a method that gets two dates as String and calculate the difference and then write the difference in a format such as "3 days 10 hours 2 minutes 39 seconds".


    We are developing a training calendar for a runner. Runner must go for a measurement session in a hospital once in 10 day. If the 10th day is Sunday, the day must be postponed to Monday. Print next 4 measurement days assuming that today is 05 August 2016.

    Create a class Training and add “public static void printDates(String today, int interval)” method. Do the following in this method:

    1. Convert today to Date instance and then calendar instance. 
    2. Add 10 days. 
    3.  If day is not Sunday, print it as mm-dd-yyyy. Else postpone to Monday. 
    4.  Repeat this 4 times. 

    Students Who Viewed This Course Also Viewed

    • Loading
    • Loading
    • Loading

    Instructor Biography

    Talha Ocakçı, Java SE, Java EE and Android Trainer

    I have bachelor and Msc degree on computer science engineering from one of the best universities in Turkey, Yeditepe University.

    I have been working as software architecture for more than 6 years and developed many scalable, reusable CRM, e-state, campaign management systems in companies like Huawei, Ebay Turkey and Nortel Netas. I am specialized in JSF 2.0 and PrimeFaces,Struts 2.0 and Spring MVC for MVC structure, Spring for dependency injection, Hibernate for ORM, Oracle, PostgreSql as RDBMS, MongoDB for NoSQL, EhCache for caching, Android Programming, Semantic Web Programming.

    I have taught Java EE, JSP/ Servlet basics and Android Programming to many colleagues in several companies like Huawei, EBay Turkey and universities like Yeditepe University.

    Ready to start learning?
    Take This Course