Java 8 Core Development - Prepare for OCJA OCJP
4.4 (61 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.
757 students enrolled
Wishlisted Wishlist

Please confirm that you want to add Java 8 Core Development - Prepare for OCJA OCJP to your Wishlist.

Add to Wishlist

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 (61 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.
757 students enrolled
Created by Talha Ocakçı
Last updated 1/2017
English
Current price: $10 Original price: $90 Discount: 89% off
1 day left at this price!
30-Day Money-Back Guarantee
Includes:
  • 21 hours on-demand video
  • 2 Articles
  • 46 Supplemental Resources
  • 5 Coding exercises
  • Full lifetime access
  • Access on mobile and TV
  • Certificate of Completion
What Will I 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
  • Create a user interface by using swing
View Curriculum
Requirements
  • Will to spend time on exercises
  • Will to spend time on theory of each topic
  • Basic computer skills
Description

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

Have a great experience!!!


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
Students Who Viewed This Course Also Viewed
Curriculum For This Course
Expand All 169 Lectures Collapse All 169 Lectures 21:40:38
+
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
08:35

Introduction to Java
3 questions

Preparing development environment
08:53

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
13:37
+
Programming with Java 101
24 Lectures 01:45:04

All the source files used throughout the course is here:

ALL SOURCE CODE IS HERE
00:01

Creating variables and assigning values.

Running our very first application.

Hello World Application
16:47

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
04:13

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
03:40

You will do some mathematical operations on primitive variables.

Exercise 1 - Mathematical operations on int variables
1 page

Solution of exercise 1
05:06

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
06:43

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
07:01

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
06:16

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
02:02

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
08:03

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
02:53

Exercise 4 - Applying operator precedence
1 page

Solution to exercise 4
03:34

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
03:32

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
11:20

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
09:13

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
03:31

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
07:20

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;

System.out.println(c);

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
03:49
+
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
09:23

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
07:34

•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
07:43

"while" loop is the alternative to for loop.

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

While Loop
03:33

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
07:57

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
08:13

Nested Loops 2 - Dependent Boundaries
04:08

Exercise - Using nested loops
1 page

Solution to exercise
06:07

Exercise - Using nested loops 2
1 page

Solution to exercise - Using nested loops
08:09
+
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
08:24

•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
03:52

  • 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
05:16

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

System.out.println(myGreatArray[i]);

}

Iterating over array elements
06:50

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
24:21
+
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
06:18

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
07:06

  • 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
    07:16

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

  • Method Invocation 1
    07:03

    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
    08:17

    • 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
    04:29

    • 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
    10:27

    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.

    Constructors
    11:03

    Static context
    07:03

    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
    09:59
    +
    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
    06:50

    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
    11:11

    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
    09:53

    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
    09:31

    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
    05:57
    +
    Object Oriented Basics
    4 Lectures 17:35

    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:

    •Modularity

    •Extensibility

    •Reausability

    Object Oriented Introducton
    02:51

    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
    04:28

    •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
    10:14

    Other object oriented concepts
    00:02
    +
    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
    07:57

    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)
    09:03

    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
    10:37

    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
    07:27

    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
    12:23

    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
    15:09

    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
    07:38

    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
    09:47

    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
    13:14

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

    btocakci@

    •btocakci@d

    •talha ocakci@gmail.com

    •btocakci@@

    •TALHAOCAKCI@gmail.com

    •btocakci@@yahoo.com

    •btocakciatgmail.com

    •talha.ocakci@gmail.com

    •talha_ocakci@gmail.c.uk

    •talha_ocakci@gmail.co.uk

    •talha-ocakci@gmail.com.tr

    •talhaocakci65@gmail.com

    •talha_ocakci@gmail.co.45

    •talha@45.net.tr

    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

    https://www.udemy.com/java-8-core-training-/learn/?instructorPreviewMode=student#/lecture/3699776

    will be parsed to:

    domain: udemy.com

    protocol: https

    course url: java-8-core-training-

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

    Extracting useful data from input with regex and matcher.group() method
    14:00
    +
    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
    11:32

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

    Used for simple time comparisons and string-time conversions

    Date Class
    08:55

    •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
    05:43

    •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
    12:01

    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
    06:26

    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
    13:51

    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
    11:28

    BigDecimal
    14:46

    BigDecimal Aritmetic Operations, setScale and toPlainString method.
    1 question

    StringBuffer
    09:47

    StringBuffer - append() and insert() methods.
    1 question

    Enum
    15:47

    Using enums
    1 question
    +
    Inheritance and Abstraction
    14 Lectures 01:58:51

    Inheritance is to create a new class by taking a pre-existing class as a base.

  • Pre-existing base class is called as super class.
  • New class that uses the super class is called as derived class or sub-class.
  • Introduction to inheritance
    05:52

    Inheriting the behaviours of another class is made by extending this class with extends keyword.

    Extending classes
    07:48

    Derived class may change a method that implemented in the super class.

    That is called as overriding a method. This is all about polymorphism in object oriented programming.

    Overriding Methods
    07:17


    We are developing the online system of a tour agency. This agency has several transport vehicles:

    Car, bus and planes. Cars may be rent to 4 people (sharing economy); buses and planes could be taken a seat. All the vehicles have some seats with constant seating plan.

    Solve the problem by inheritance:

    • Design a super class with some methods and attributes.
    • Create subclasses, override the methods and define attribute values.
    • Use private and protected access modifiers to encapsulate critical data.
    Preview 22:23


    Object is super class for all Java classes

    Any class without explicit extends clause is a direct subclass of Object. Because all of the object instances have some common features:

  • Logical comparison to other instances with the same type : equals() method
  • Summarizing the data inside as a string : toString() method
  • Summarizing the data inside according to a customized algorithm : hashCode() method
  • toString() method returns String representation of object; describes state of object

    •Automatically called when:

    •Object is concatenated with a String

    •Object is printed using print() or println()

    •Object reference is passed to assert statement of the form

  • Object class and toString() method
    10:13

    Method equals() tests whether two objects have same contents By contrast, == operator test 2 references to see if they point to the same object
    Object class - equals() method
    12:28

    We are working for a health insurance company project. The requirement is that:

    Validity date of an insurance policy can be defined in months, days or weeks. Assuming that 1 month = 4 weeks = 7 days We need to create a class called as MyTime and represent the times with different units. When we compare two MyTime instances with equals() method, if the values are equivalent, result should be true.

    Exercise: equals() method overriding
    2 pages

    Hashing means summarising the data so that it can be categorised later on.

    Hashing is the technique used to find elements in a data structure quickly, without doing full linear search .

    Hashing in Java is done with hashCode() method in Object class.

    Object class - hashcode() method
    07:22

    Abstraction means

    1.Hiding the details of a process from the requestor.

    2.Defining a contract for the client and service provider

    3.Defining a contract for all providers should accept before servicing to clients.

    Abstraction
    05:07

    Interface is an element of Java to implement abstraction.

    It defines no implementation, only contract

    Interface
    10:26

    Abstract class is another element of Java to implement abstraction.

    Abstract class is a contract that define the overall structure and with some possible implementation details.

    An instance of abstract class cannot be instantiated. Should be extended and all the methods must be implemented.

    Abstract class
    15:26

    If you have multiple instances, you can not put them into the same collection. Even if you put, while iterating over the collection, you possibly will get RuntimeExceptions.

    But all of your classes of instances derive from a single class and you iterate over the collection as if they all have the same class (base class), everything executes perfectly.

    This is an advantage of polymorphism.

    Confused? Come on in to learn the details.

    Storing objects with different types but same super class in array
    04:11
    4 More Sections
    About the Instructor
    Talha Ocakçı
    4.5 Average rating
    108 Reviews
    2,144 Students
    3 Courses
    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.