Object Oriented Programming in Java for beginners

Object Oriented Programming in Java for beginners

Made for Learners

About the Book

In this book, we will learn about the basics of Object-Oriented Programming (OOP) in Java. OOP is a paradigm that provides many concepts, such as inheritance, polymorphism, etc. The main objectives of OOP is to implement real-world entities, for example, object, classes, abstraction, inheritance and polymorphism.

If you are new to Java, and you want to learn the concept of OOP, yes, this book is for you. This book uses many illustrations, diagrams, tables, and examples for readers to understand how OOP works. You can do the examples on you own to test your understanding.

About the Author

N.I. Zain
N.I. Zain

The author had published numbers of paper publication in various area in Engineering since 2013. To make a good use of what the author has learn, the author decided to write some technical books to share to learner out there for them to read.

Table of Contents

  • Table of Content
  • COPYRIGHT
  • About the book
  • Table of Content
  • CHAPTER 1 GETTING STARTED WITH JAVA
  • 1.1 INTRODUCTION
  • 1.2 INSTALLING JAVA (WINDOWS 10)
  • 1.2.1 Checking the Java Version
  • 1.2.2 Download Java for Windows 10
  • 1.2.3 Install Java on Windows 10
  • Step 1: Run the Downloaded File
  • Step 2: Configure the Installation Wizard
  • 1.2.4 Set Environmental Variables in Java
  • 1.2.5 Test the Java Installation
  • 1.2.6 Making Sure Java Is Working
  • Step 1: Write and Save Java program (HelloWorld.java)
  • Step 2: Compile and Run the HelloWorld.java
  • CHAPTER 2 INTRODUCTION
  • 2.1 JAVA SOURCE FILE STRUCTURE
  • 2.2 CLASS DEFINITION
  • 2.2.1 Number of classes and public classes
  • 2.2.2 Saving the Java file
  • 2.2.2.1 Example – Creating classes and saving the Java file
  • 2.2.2.2 Example – Adding ‘public’ to the class and saving the Java file
  • 2.2.2.3 Example – Two public classes in a single Java program
  • 2.2.3 Public class name, java file name, and main class method
  • 2.2.3.1 Example – Creating classes, saving, compiling, and running the code
  • 2.3 IMPORT STATEMENT
  • 2.3.1 Java import statement
  • 2.3.2 How naming conflict in Java import statement happen?
  • 2.4 HIGHLIGHTS ON IMPORT STATEMENT
  • 2.4.1 No import statement is required when using class provided in java.lang package
  • 2.4.2 No import statement is required if any class is present in current working directory
  • 2.4.3 Package and sublevel package
  • 2.5 PACKAGE STATEMENT
  • 2.5.1 Built-in package
  • 2.5.2 User-defined package
  • 2.6 HIGHLIGHTS ON PACKAGE STATEMENT
  • CHAPTER 3 OBJECT, CLASS, AND CONSTRUCTOR
  • 3.1 OBJECT AND CLASS
  • 3.1.1 Variables
  • 3.1.1.1 Local variables
  • 3.1.1.2 Instance variables
  • 3.1.1.3 Class variables / Static variables
  • 3.2 A CONSTRUCTOR - WHAT IS IT, WHY NEED IT, AND HOW TO WRITE IT?
  • 3.2.1 What is constructor?
  • 3.2.2 Why is constructor used in programming?
  • 3.2.3 How to write a constructor?
  • 3.3 OBJECT CREATION BY DECLARATION, INSTANTIATION, AND INITIALIZATION
  • 3.3.1 Understanding the object creation and constructor
  • 3.4 ACCESSING METHOD
  • CHAPTER 4 ACCESS MODIFIER
  • 4.1 ACCESS MODIFIER
  • 4.2 PUBLIC ACCESS MODIFIER
  • 4.2.1 Example – Public class
  • 4.2.2 Example – Public method
  • 4.3 DEFAULT ACCESS MODIFIER
  • 4.3.1 Example – Creating object and accessing method in the same package using default access modifier
  • 4.3.2 Example - Accessing default method in default class from different package
  • 4.3.3 Example - Default Method in Public Class
  • 4.4 PRIVATE ACCESS MODIFIER
  • 4.4.1 Example - Accessing private method from different class
  • 4.5 PROTECTED ACCESS MODIFIER
  • 4.5.1 Example – Child class and parent class
  • 4.5.2 Example - How many possible ways of accessing protected method within the same package?
  • 4.5.3 Example - How to access protected method from different package?
  • 4.6 SUMMARY OF PUBLIC, DEFAULT, PRIVATE AND PROTECTED ACCESS MODIFIER.
  • CHAPTER 5 ABSTRACT AND INTERFACE
  • 5.1 ABSTRACT MODIFIER
  • 5.1.1 Abstract method
  • 5.1.1.1 Example – Declaring abstract method
  • 5.1.1.2 Further understanding on abstract method
  • 5.1.2 Abstract class
  • 5.1.2.1 Example - Does Every Abstract Class have Abstract Method?
  • 5.1.2.2 Example - Does every abstract class have abstract method?
  • 5.1.3 Abstract method and abstract class
  • 5.1.3.1 Example – Implementing abstract method
  • 5.1.3.2 Example - Creating object from abstract method and class
  • 5.2 INTERFACE
  • 5.2.1 Definition 1
  • 5.2.1.1 Case 1
  • 5.2.1.2 Case 2
  • 5.2.2 Definition 2
  • 5.2.3 Interface declaration and implementation
  • 5.2.3.1 Mistake Number 1
  • 5.2.3.2 Mistake Number 2
  • CHAPTER 6 DATA HIDING, ABSTRACTION, AND ENCAPSULATION
  • 6.1 DATA HIDING
  • 6.1.1 Example - How to implement data hiding in programming
  • 6.2 ABSTRACTION
  • 6.3 ENCAPSULATION
  • 6.3.1 Example – How to encapsulate data member and behavior into one group
  • 6.3.2 Tightly Encapsulated Class
  • CHAPTER 7 INHERITANCE
  • 7.1 WHAT IS INHERITANCE?
  • 7.1.1 Example – Inheritance Case 1
  • 7.1.2 Example – Inheritance Case 2: Parent to child
  • 7.2 THE IMPORTANCE OF INHERITANCE
  • 7.3 TYPE OF INHERITANCE
  • 7.3.1 Single inheritance
  • 7.3.2 Multiple inheritance
  • 7.3.3 Multi-level inheritance
  • 7.3.4 Hierarchical inheritance
  • 7.3.5 Hybrid inheritance
  • 7.3.6 Why is multiple inheritance not supported in Java?
  • CHAPTER 8 POLYMORPHISM
  • 8.1 UPCASTING AND DOWNCASTING IN JAVA
  • 8.1.1 Upcasting
  • 8.1.2 Example – Example of Upcasting
  • 8.1.2.1 Further discussion of the result
  • 8.1.3 Downcasting
  • 8.1.3.1 Example – Example of downcasting
  • 8.1.3.2 Further discussion of the result
  • 8.1.4 Difference between upcasting and downcasting
  • 8.2 POLYMORPHISM
  • 8.2.1 Example – Polymorphism in Java
  • 8.2.2 Example – Runtime polymorphism/ dynamic polymorphism with method overriding
  • 8.2.3 Example - Compile-time polymorphism/ static polymorphism with method overloading
  • What’s Next?

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

80% Royalties. Earn $16 on a $20 book.

We pay 80% royalties. That's not a typo: you earn $16 on a $20 sale. If we sell 5000 non-refunded copies of your book or course for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earnedover $13 millionwriting, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub