Java Programming with Java 8 and OCA OCP Java Exam Prep
3.7 (255 ratings)
Course Ratings are calculated from individual students’ ratings and a variety of other signals, like age of rating and reliability, to ensure that they reflect course quality fairly and accurately.
1,585 students enrolled

Java Programming with Java 8 and OCA OCP Java Exam Prep

Full syllabus of a classroom-based Java 8 training and exam prep with theory, exercises and lab sections.
3.7 (255 ratings)
Course Ratings are calculated from individual students’ ratings and a variety of other signals, like age of rating and reliability, to ensure that they reflect course quality fairly and accurately.
1,585 students enrolled
Created by Talha Ocakçı
Last updated 9/2018
English [Auto]
Current price: $62.99 Original price: $89.99 Discount: 30% off
5 hours left at this price!
30-Day Money-Back Guarantee
This course includes
  • 26 hours on-demand video
  • 3 articles
  • 64 downloadable resources
  • 1 Practice Test
  • 6 coding exercises
  • Full lifetime access
  • Access on mobile and TV
  • Assignments
  • Certificate of Completion
Training 5 or more people?

Get your team access to 4,000+ top Udemy courses anytime, anywhere.

Try Udemy for Business
What you'll learn
  • 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
  • Using Java 8 streams and functional programming
  • Using databases with Java applications
  • Create a user interface by using swing
Course content
Expand all 208 lectures 26:43:50
+ Course Introduction
4 lectures 34:51

The tools we will use will be explained.

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

Preview 03:46

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.

Platform Independency, JDK and JRE terms
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.

Syntax rules
+ Programming with Java 101
24 lectures 01:45:04

All the source files used throughout the course is here:


Creating variables and assigning values.

Running our very first application.

Hello World 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.

Importing project - Exporting Project

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.

Introduction to primitives and int

You will do some mathematical operations on primitive variables.

Exercise 1 - Mathematical operations on int variables
1 page
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.

long and short types

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.

Casting integer types

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!

Exercise 2 - Casting integer types
2 pages
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.

Floating Point Numbers - float and double
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
Exercise 3 - Using floating point numbers
2 pages
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.

Operator Precedence
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
Shortcut Operators

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.

Boolean type and logical operations

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 ! .

Exercise 5 - Boolean operation construction
2 pages
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.

Printing values to console. print and println methods
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:

char and character arithmetic
Character and character arithmetic
2 questions

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.

Exercise 6 - Character Arithmetic - Modifying char with arithmetic operations
1 page
Solution to exercise 6 - Modifying char with arithmetic operations
+ Control Structures and Loops
13 lectures 01:02:47

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.

If else blocks

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.”

Exercise - If else block construction
1 page
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.

Switch Statement

•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”.

For loop

"while" loop is the alternative to for loop.

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

While Loop

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

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

Exercise - Using "for" loops
1 page

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

Breaking the loops

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
Nested Loops 2 - Dependent Boundaries
Exercise - Using nested loops
1 page
Solution to exercise
Exercise - Using nested loops 2
1 page
Solution to exercise - Using nested loops
+ Array
5 lectures 48:43
  • 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 [];
Introduction to arrays

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

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

Initializing the array without specifying the size
  • 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.
Why array indexes start at 0 and ArrayIndexOutOfBoundsException

•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++){



Iterating over array elements
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.

Multi-dimensional arrays
+ Class and Method
12 lectures 01:19:01
  • 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.

Object, Class, Instance Definitions

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.

Creating and referencing instances
  • 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.

  • Method Theory
  • A method MUST be inside a class.
  • A method (mostly) MUST be invoked from an instance of a class.

  • Method Invocation 1

    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)

    Method Invocation 2 - Invoke on object instances
    • Design and create a class.
    • Create an instance by new keyword.
    • Accessing / modifying attributes and methods of an instance.
    Exercise - Using classes, instances and invoking methods
    2 pages

    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.

    Exercise - Code Correction - Return value on all flow paths
    1 page

    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)

    Method Overloading
    • 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)

    Limitless arguments - Array and Vararg arguments

    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

    Using static variables and methods
    + Memory management in Java
    5 lectures 43:22
    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.

    Introduction to JVM memory management
    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.

    Preserving Method Execution Order

    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.

    Stack Space and StackOverflowError

    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.

    Modifying object instances inside method

    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.

    Modifying primitive arguments inside method

    How the invocation order of methods are preserved?

    What is local variables?

    Method invocation order and method-local variables
    4 questions
    + Array exercises and live coding
    2 lectures 34:40
    Exercise - Finding series in an array
    Exercise - Multidimensional arrays and methods
    + Object Oriented Basics
    4 lectures 17:36

    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:




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

    This is called as composition.

    Composition - Composing object instances

    •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.

    Data Encapsulation and Access Modifiers
    Other object oriented concepts
    + String Object and Regular Expressions
    14 lectures 02:01:52

    String is used for storing texts in Java programs.

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

    Introduction to string

    String equality is done by equals() method.

    Never ever use == for comparing strings.

    Watch the lecture and see the details.

    Checking string equality (Pooled string)

    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

    String methods - 1

    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.

    String methods - 2

    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)

    Exercise 1 - Count Words
    1 page
    Solution to exercise 1- Finding occurrence count of a word in a sentence

    You will learn

    • Using overloaded versions of indexOf() method.
    • Using substring() method to extract words.
    Exercise 2 - Remove words from string
    1 page
    Solution to exercise - Removing all occurrences of a word from a sentence
    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.

    Exercise 3 - Convert to title case
    1 page
    Solution to exercise 3 - Making a sentence title-case

    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.

    Regular expressions - Introduction

    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.

    Regular expressions - Further Examples

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















    Preview 14:37
    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

    Extracting useful data from input with regex and method
    + Most Used Built-in Classes
    10 lectures 01:50:16

    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.
    Integer, Float, Double, Boolean,Character Classes - Boxing and Unboxing

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

    Used for simple time comparisons and string-time conversions

    Date Class

    •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

    Date Formatting with SimpleDateFormat

    •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.

    Calendar Class

    How to convert

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

    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".

    Exercise - Find difference between two dates as human readable

    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. 
    Exercise - Finding a future date
    BigDecimal Aritmetic Operations, setScale and toPlainString method.
    1 question
    StringBuffer - append() and insert() methods.
    1 question
    Using enums
    1 question
    • Will to spend time on exercises
    • Will to spend time on theory of each topic
    • Basic computer skills


    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

    9- Java 8 Date and Time API

    10- Generics

    11- Java and Database Interaction with MySQL 

    Have a great experience!!!

    Who this course is for:
    • Even with no experience in programming
    • Programmers with even no experience in object oriented programming
    • Programmers that already know an object oriented programming language