Table Of ContentMastering Java
An Effective Project Based Approach
including Web Development, Data
Structures, GUI Programming and Object
Oriented Programming (Beginner to
Advanced)
Copyright 2018 by Michael B. White - All rights reserved.
This book is geared towards providing precise and reliable information about
the topic. This publication is sold with the idea that the publisher is not
required to render any accounting, officially or otherwise, or any other
qualified services. If further advice is necessary, contacting a legal and/or
financial professional is recommended.
From a Declaration of Principles that was accepted and approved equally by a
Committee of the American Bar Association and a Committee of Publishers’
Associations.
In no way is it legal to reproduce, duplicate, or transmit any part of this
document, either by electronic means, or in printed format. Recording this
publication is strictly prohibited, and any storage of this document is not
allowed unless with written permission from the publisher. All rights
reserved.
The information provided herein is stated to be truthful and consistent, in that
any liability, in terms of inattention or otherwise, by any usage or abuse of
any policies, processes, or directions contained within, is the solitary and
utter responsibility of the recipient reader. Under no circumstances will any
legal responsibility or blame be held against the publisher for any reparation,
damages, or monetary loss due to the information herein, either directly or
indirectly.
Respective authors own all copyrights not held by the publisher.
The information herein is offered for informational purposes solely, and is
universally presented as such. The information herein is also presented
without contract or any type of guarantee assurance.
The trademarks presented are done so without any consent, and this
publication of the trademarks is without permission or backing by the
trademark owners. All trademarks and brands within this book are thus for
clarifying purposes only and are the owned by the owners themselves, and
not affiliated otherwise with this document.
Table of Contents
Introduction
Chapter 1: Java Basics
Setting Up Your Environment
The JVM (Java Virtual Machine)
How It All Works
Your First Program
Java Comments
Code Structure
Introducing Data Types and Variables
Example
Reserved Keywords
Double Variables
Short Variables and Float Variables
Operator Precedence
Storing Text Values
Receive and Read User Data in Java
The IF Statement
The IF…ELSE Statement
The IF…ELSE IF Statement
The Nested IF Statement
Boolean Values
Switch Statements
Statements – Loops and Iteration
Arrays
Arrays and Loops
Sorting Arrays
Arrays and Strings
Multi-Dimensional Arrays
Functions and Methods
Classes and Objects
Import Statements
Chapter 2: Java Data Structures and Algorithms
An Overview of Data Structures
Classification of Data Structures
An Overview of Algorithms
Basic Terminology
Characteristics of an Algorithm
Time Complexity and Time Complexity Functions
Basic Concepts of Data Structures and Algorithms
What Is An Array?
Searching and Sorting Algorithms
Multi-Dimensional Arrays and Matrix Multiplication
Singly Linked Lists – Search and Sort Algorithms
Doubly Linked and Circular Linked Lists and Algorithms
Stacks
Chapter 3: Java Web Development
Ajax Development with JavaScript
Creating the Java Package and Source File
Troubleshooting
Web Services
The Entity Class and Session Facade
Introducing JavaServer Faces
Introducing Ajax for Java
Connecting to a MySQL Database
Application and Database Communication
Using jQuery to Improve a Web Page
Chapter 4: Java GUI Programming
GUI Programming with AWT
Label
Examples
MouseEvent and MouseListener Interface
KeyEvent and KeyListener Interface
Nested Classes
Adaptor Class Event Listeners
An Introduction to Swing
Content-Pane in JFrame
NetBeans for Java
Java Application Development
Java GUI Tools
Chapter 5: Object-Oriented Programming
Why OOP?
OOP Concepts
Java Constructors
Accessing Parent Class Variables
The Java OOP Concepts
Abstraction
Encapsulation
Polymorphism
Inheritance
Association
Aggregation
Composition
Abstraction
Interface
Encapsulation
Inheritance
Polymorphism
Association, Aggregation, and Composition
Best Practice Guide for OOP
Composition is Better than Inheritance
Java OOP – Miscellaneous
Math Class
Java Calls by Value and Reference
Java Command Line Arguments
Java Method Overriding
Java Method Overloading
Difference Between Overloading and Overriding
Chapter 6: Java Interview Questions
Basic Java Interview Questions
OOPS Java Interview Questions
JDBC Interview Questions
Hibernate Interview Questions
Java JSP Interview Questions
Chapter 7: Java Language and Terminology
A
B
C
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
Z
Conclusion
References
Introduction
First, let me thank you for taking the time to purchase and read my guide,
“Mastering Java: An Effective Project-Based Approach including Web
Development, Data Structures, GUI Programming and Object Oriented
Programming.”
My intention with this guide is to teach you all about the Java computer
programming language. To that end, I have sectioned the guide into 6
separate sections, each one dealing with a separate element of Java
programming. You will learn:
Chapter 1: Java Basics – you will learn the basic programming elements of
the Java language, including how to set up your programming environment,
using a text editor and how to write a program. We look at comments, how to
structure your code, and what data types and variables are. We also look at
how to receive and read Java data, the different types of statement, loops and
arrays before moving on to functions and methods. By the end of this section
you will have a firm understanding of how to program in Java.
Chapter 2: Java Data Structures and Algorithms – in this section we will
examine a part of Java programming that is very important to computer
science. You will learn exactly what a data structure is, how they are
classified and the design of them, before moving on to algorithms. We learn
how to write an algorithm, what asymptotic analysis and notation are and the
definition of a greedy algorithm. We learn how data structures and algorithms
mesh together, the different methods of sorting and traversing algorithms to
gain information before moving onto trees and finishing with recursion.
Chapter 3: Java Web Development – this section will walk you through all
the elements of developing a web app using Java. We look at JSP and servlets
and how they are used in building web apps, before looking at some of the
best practices in web development using Java EE (Enterprise Edition). This is
an involved chapter with plenty of technical information and a hands-on
guide that you can easily follow.
Chapter 4: Java GUI Programming – GUI programming is a complex part
of Java programming and, in this section we look at using NetBeans and
Swing to build a Java GUI. We discuss native packaging, followed by a
tutorial that you can follow along with, covering how to design a GUI using
the NetBeans IDE. We talk about how to handle images, design forms, gap
editing and debugging, followed by a discussion on bean and data binding
and using Hibernate in your application.
Chapter 5: Object-Oriented Programming – this section covers object-
oriented programming in Java; what it is, the benefits of the approach, the
principles of Object Oriented Programming (OOP) and understanding the
basic concepts.
Chapter 6: Java Interview Questions – lastly, I have provided you with a
comprehensive list of questions that you could be asked in an interview for a
Java programming job. I also provide the answers with the intention being
that you study them and learn them; not just what the answers are but the why
and how too.
Java is not a new programming language by any means; it has been around
since 1991 and, to date, has proved to be the most popular, especially where
web development is concerned. It is one of the simplest languages to learn,
and it is object-oriented, which makes it even easier to learn.
Work your way through this guide and, by the end of it, you will know more
than many people do about the Java programming language and all its uses. I
would make one suggestion – if you choose to join in and input the code
yourself, do type it in rather than copying and pasting. It’s a great way of
getting the feel for programming and how things work.
Thank you once again for choosing my guide.
Chapter 1: Java Basics
There is no doubting that Java is the most popular and the most used
computer programming language of all, in particular where web platforms
and web applications are concerned. Java was deliberately designed to be
incredibly flexible with the express intention of allowing developers to write
code that would work on any machine, irrespective of its architecture and the
platform in use. At the time of writing, well over one billion computers and
over three billion mobile devices are built on Java.
You will find Java being used as the basis for platforms and applications on a
huge range of devices:
● Laptops
● Desktop computers
● Satellite navigation systems
● Games consoles
● Medical monitoring devices
● Parking meters
● Lottery terminals
● Smartphones
● Mobile tablets
● Blu-ray players
And a whole lot more. Plus, Java is also one of the major languages that are
used for networking; more specifically for data centers responsible for storing
web-based data and for transferring it.
If that weren’t enough, Java is also used for creating dynamic but small
programs embedded in web pages, or running beside them. These are known
as applets and you will find them in widgets that display maps, the weather,
games and any other widget or tool on a web page that is interactive in some
way.
Java is a class-based and an object-oriented language that is based firmly on
the programming syntax for both C and for C++ languages. Developers tend
to go for Java over and above the other programming languages because of
its flexibility in securely running on just about any platform, regardless as we
said earlier, of the architecture of the platform or the operating system it runs
on. So long as the device in question has got Java Runtime Environment