Java Programming with Java 8 and OCA OCP Java Exam Prep
- 26 hours on-demand video
- 3 articles
- 64 downloadable resources
- 1 Practice Test
- 6 coding exercises
- Full lifetime access
- Access on mobile and TV
- Certificate of Completion
Get your team access to 4,000+ top Udemy courses anytime, anywhere.Try Udemy for Business
- 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
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.
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.
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.
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.
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 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 ! .
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.
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.
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.
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 x is the starting address of an array;
- arr => x
- •arr => 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.
- 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.
§ 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.
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)
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.
- 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.
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
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.
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.
•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.
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.
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:
- You will use regular expressions to break a sentence from, one blank character, multiple blank character, a punctuation mark, a new line character.
- 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.
You will learn how to parse a url into its elements. For instance
will be parsed to:
course url: java-8-core-training-
internal url: learn/?instructorPreviewMode=student#/lecture/3699776
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.
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:
- Convert today to Date instance and then calendar instance.
- Add 10 days.
- If day is not Sunday, print it as mm-dd-yyyy. Else postpone to Monday.
- Repeat this 4 times.
- Will to spend time on exercises
- Will to spend time on theory of each topic
- Basic computer skills
NEW: ONLINE CODE PRACTICES ARE ADDED. YOU STUMBLED UPON THE FIRST JAVA COURSE WITH UDEMY ONLINE CODE PRACTICES.
Read the problem, write your code and get the feedback automatically. That's it!
[ALL SOURCE CODE IN THE FIRST LECTURE. JUST IMPORT AND TEST!!!]
[FIRST STEP TO PREPARATION FOR THE ORACLE CERTIFICATION EXAMS: OCJA and OCJP]
[MOST CHAPTERS HAVE A GREAT EXERCISE AND ITS SOLUTION IN DETAILS]
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
11- Java and Database Interaction with MySQL
Have a great experience!!!
- Even with no experience in programming
- Programmers with even no experience in object oriented programming
- Programmers that already know an object oriented programming language