Java Tutorial

Java Tutorial, Java Programming Environment Setup, Java Syntax, Java Language Fundamentals, and Java Object-Oriented Programming.

Java Programming language was developed by James Gosling with his team (Java Team, also known as Green Team) in 1995 for Sun Microsystems, later Java was acquired by Oracle in 2010.

Java is a General-purpose programming language, to be used for writing software in the widest variety of application domains.

Java is a Programming Language and a Platform, Java is used as programming to develop Software Applications, and It also used as a Software Platform to run Java applications.

Java is used to develop,

• Desktop GUI Applications,
• Web Applications,
• Enterprise Applications (Banking, ERP, Ecommerece, etc,),
• Mobile Applications,
• Scientific Applications,
• Embedded Systems,
• Big Data Technologies Distributed Applications,
• Cloud-based Applications,
• Web servers and Application servers,
• Software Tools (JMeter, Selenium, SoapUI were developed using Java),
• Gaming Applications,
and Smart Cards, etc,

Java Tutorial

Java Programming Language Syllabus

1. Introduction to Java Programming
2. Java Environment Setup
3. Java Keywords and Identifiers
4. Java Basic Syntax
5. Java Program Structure.
6. Comments in Java
7. Modifiers in Java.
8. Java Data Types.
9. Variables in Java.
10. Operators in Java
11. Java Control Flow – Decision Making Statements.
12. Java Control Flow – Looping Statements.
13. Java Control Flow – Branching Statements.
14. Java Strings
15. Java Numbers
16. Java Characters
17. Java – Date and Time
18. Java Arrays
19. Java ArrayList
20. Java IO – Read User Input.
21. Java IO – File Handing.
22. Java Methods – User-Defined Methods
23. Java Methods – Built-in Methods
24. Exception Handling in Java
25. Java Object-Oriented Programming
26. Java Inheritance.
27. Java Polymorphism.
28. Java Abstraction.
29. Java Encapsulation.
30. Java Interfaces
31. Java Certification


Java Tutorial for Beginners

1. Introduction to Java Programming

Java Language was initially developed for digital devices such as set-top boxes, televisions, etc. now it is used for various types of application development.

Introduction: 

1. What is Java?
2. History of Java
3. Features of Java
4. JDK, JRE, and JVM
5. Editions of Java
6. Applications of Java Programming

Introduction to Java Programming


2. Java Environment Setup

Java Installation and Environment Setup, Download & Install Java JDK software, set Java Environment variable, and Install Eclipse IDE.

Java supports various operating environments like MS Windows, Linux, Macintosh, etc, to write & execute Programs.

To write and execute Java programs then Java Environment is required.

Three important steps in Computer programming,

1. Write a Program (in an Editor)
2. Compile the Program
3. Run the Program

Java Installation and Environment Setup


3. Java Keywords and Identifiers

Java keywords are also known as reserved words. Keywords are particular words that act as a key to a code. These are predefined words by Java so they cannot be used as identifiers.

Identifiers in Java are symbolic names used for identification. They can be a class name, variable name, method name, package name, constant name, and more.

Note: Java keywords or reserved words can not be used as an identifier.

Java Keywords and Identifiers


4. Java Basic Syntax

Java Programming Syntax:

1. Case Sensitivity
2. Comments in Java
3. Java Program File Name
4. Java Class Names
5. Java main() Method
6. Java Method Names
7. Java Identifiers
8. Java Keywords
9. White-spaces and Blanks lines in Java
10. Java Modifiers
11. Java Statements and Code blocks
12. Explicit Declarations of Data Types & Variables

Java Basic Syntax


5. Java Program Structure.

Sections of Java Program:

1. Documentation Section – Optional
2. Package Statement – Mandatory
3. Import Statement/s – Depends on our program requirement
4. Interface Section //Optional
5. Class Definition
{ //Mandatory //Variables and Methods Declarations.
6. main method()
{ //Main Program contains normal statements and code blocks Object Creation //Depends on our program requirement Declarations/Initialization/Reading – normal statements Operations, Display statements, etc… Code Blocks, Conditions/Decision-making blocks, Loop Blocks, Constructor Block., Etc…
}

}

Java Program Structure


6. Comments in Java

The Java comments are the statements that are not executed by the compiler and interpreter.

The comments can be used to provide information or explanation about the variable, method, class, or any statement.

The comments can be used to hide program code.

Note: The primary purpose of comments is to make the code understandable and the secondary purpose of comments is to make the code prevent execution.

Java supports single line, multi-line, and Documentation comments.

Comments in Java


7. Modifiers in Java.

Java provides a rich set of modifiers. They are used to control access mechanisms and also provide information about class functionalities to JVM.

Java has two categories of modifiers:

1. Access Modifiers :
Access Modifiers can be used to define access control for classes, methods, and variables. Java has four access modifiers, public, private, protected, and default.

2. Non-access Modifiers:
In java, we have seven non-access modifiers. They are used with classes, methods, variables, constructors, etc to provide information about their behavior to JVM.

Access and Non Access Modifiers in Java


8. Java Data Types.

Data Type is a classification of the type of data that a Variable or Constant or Method can hold in computer programming. Example:

Character, Number, Number with decimal values, Logical data, String, Date, Currency, etc…

Note: Java supports the explicit declaration of Data Types.
(We need to specify the Data Type before declaring Variables, Constants, and methods…)

Two Categories of Data Types in Java

1. Primitive Data Types
2. Non-primitive data Types

1. Primitive Data Types

i. byte (8 bits)
ii. short (16 bits)
iii. int (32 bits)
iv. long (64 bits)
v. float (32 bits)
vii. character
viii. boolean

2. Non Primitive data types / Reference data types

Non Primitive data types in Java are Objects (String, Array etc…)

Data Types in Java


9. Variables in Java.

Variable is a named memory location to store the temporary data within a program.

We have variables in every computer programming language, the use of variables is the same for all programming languages but syntax varies from one language to another.

1. What is a Variable?
2. Declaration of Variables
3. Assign values to variables
4. Variable Naming Restrictions
5. Types of Variables
6. Java Program Example

Java Variables


10. Operators in Java

• Operators are used to performing Arithmetic, Comparison, and Logical Operations.

• Operators are used to performing operations on variables and values.

Important Categories of Operators in Java:

1. Arithmetic Operators
2. Unary Operators
3. Relational Operators
4. Assignment Operators
5. Logical Operators
etc,

Operators in Java


11. Java Decision Making Statements

Control Flow Statements in Java

We have three types of conditional statements in computer programming.

1. Decision-making/Conditional statements (if, switch)
2. Loop Statements (for, while, do while, and enhanced for)
3. Branching statements (break, continue, and return)

Decision Making Statements in Java:

In Java, we have the following decision-making statements –

1. Java if Statements
2. Java If else Statements
3. Java if else if Statements
4. Java Nested If Statements
5. Java Switch Case Statement

Java Decision Making Statements


12. Java Loop Statements

Java Loop Statements, Java Control Flow, Java for loop, while loop, do while loop, enhanced for loop, and Java nested loop statements.

Looping in programming languages is a feature that facilitates the execution of a set of instructions/functions repeatedly while some condition evaluates to true.

We have four-loop structures in Java:

1. for loop
2. while loop
3. do while loop
4. enhanced for loop

Java Loop Statements


13. Java Branching Statements

Branching statements are used to transfer control from one point to another in the code Branching statements are defined by three keywords – break, continue and return

The break statement is used to stop the execution and comes out of the loop Mostly break statements are used in switch and in loops.

The continue statement is also the same as the break statement, the only difference is when the break statement executes it comes out from the loop, whereas the continue statement executes comes out from the loop temporarily.

The return statement is used in User-defined methods (methods with a return value) and the return statement must be always the last statement in the method.

Java Branching Statements


14. Java Strings

Java Strings, What is String?, Declare Strings in Java, String handling in Java, String Methods, String Concatenation, and String Comparison.

Operations on Strings:

1. Concatenating Strings
2. String Comparison
3. charAt()
4. equalsIngoneCase()
5. toUpperCase()
6. toLowerCase()
7. trim() Method
8. substring()
9. endsWith()
10. length

Java Strings


18. Java Arrays

Arrays in Java, What is Array in Java, Declare Arrays, Java Array built-in methods, advantages of Java Arrays, and Drawbacks of Java Arrays.

Java Arrays:

• In Java, Array is an Object that holds a fixed number of values of a single data type
• The length of the Array is established when the Array is created.
• Array length is fixed and index starts from zero to n-1,

Operations on Arrays:

1. Find an Array length.
2. Copy an Array to a String
3. Print an Array using for loop
4. Print an Array using enhanced for loop
5. Check if an Array contains a certain value or not?

Arrays in Java


19. Java ArrayList

Java ArrayList, create ArrayList, add elements to ArrayList, return ArrayList size, remove elements of ArrayList, and clear all elements of the ArrayList.

Java Array is Static Data Structure and ArrayList is Dynamic Data Structure.

Java ArrayList Operations:

1. Add elements to ArrayList
2. Return & Print an Array Element
3. Print Size of the ArrayList
4. Change an Item
5. Check the existence of Elements
6. Remove an element
7. Remove all Items

Java ArrayList


20. Read User Input

Reading User Input, Java User Input, Java Output, Java Scanner Class, Java System Class, Java File Handling, and Java Database Connectivity.

The Scanner class is used to get user input and it is available in java.util package

To use the Scanner class, create an object of the class, using any available methods perform reading operations

Writing Program output on the Console – Using the System class we can write output statements in Java.

Reading User Input


21. File Handing/File Operations

File Handling in Java, Java Input and Output operations, handling text files, create a file, read a file, write a file, and compare two files.

Java File (Text File) Operations:

1. Create a Folder on Desktop
2. Delete a Folder
3. Create a File
4. Delete a File
5. Read a Text File
6. Read a Text File (Range of Records)
7. Write Data to a Text File
8. Read a Text File and write the data to another file

File Handling in Java


22. User-Defined Methods

User-Defined Methods in Java, Java Static and Non-static methods, Java method with return a value, and java method without return a value.

What is Method?

• A Java method is a set of statements that are grouped together to perform an operation.
• Methods are also known as Functions
• In Structured programming (ex: C Language) we use Functions (Built-in and User-defined)
• In Object-Oriented Programming we use Methods (Built-in and User-defined)

User-defined Methods

Two types of User-defined Methods in Java

1. Method without returning any value
a. Calling Method by invoking Object
b. Calling Method without invoking Object

2. Method with returning a value.
a. Calling Method by invoking Object
b. Calling Method without invoking Object

User Defined Methods in Java


23. Built-in Methods

In Java, predefined methods are the method that is already defined in the Java class libraries is known as predefined methods. It is also known as the standard library method or built-in method. We can directly use these methods just by calling them in the program at any point.

When we call any of the predefined methods in our program, a series of codes related to the corresponding method runs in the background that is already stored in the library.

Categories of Built-in Methods

1. String Methods
2. Number Methods
3. Character Methods
4. Array Methods, etc,

Built in Methods in Java


24. Exception Handling in Java

An exception is a problem that arises during the execution of a program. When an Exception occurs the normal flow of the program is disrupted and the program/Application terminates abnormally.

Exception Handling is a mechanism to handle runtime errors.

Common Scenarios of Java Exceptions:

1. Scenario where ArithmeticException occurs.
2. Scenario where NumberFormat Exception occurs.
3. Scenario where NullPointerException occurs.
4. Scenario where ArrayIndexOutOfBoundsException occurs
5. Scenario where StringIndexOutOfBoundsException occurs
etc,

Exception Handling in Java


25. Java Object-Oriented Programming

Java Object-Oriented Programming, Class, Object, Method, Java Inheritance, Polymorphism in Java, Java Abstraction, and Java Encapsulation.

Java OOP concepts:

Project
Package
Class
Object
Method
Constructor
Interface

Object-oriented Programming Principles

Inheritance
Polymorphism
Abstraction
Encapsulation

Java Object Oriented Programming


26. Java Inheritance

Java Inheritance, Java Object-Oriented Programming, Types of Inheritance in Java, single inheritance, multiple inheritances, and ‘extends’ keyword.

• It is a process of inheriting (reusing) class members (Fields/Variables and Methods) from one class to another.

• The class where the class members are getting inherited is called Parent/Super/Base Class.

• The class to which the class members are getting inherited is called Child/Sub/Derived Class.

• The inheritance between parent class and child class is achieved using the ‘extends‘ keyword.

Java Inheritance


27. Polymorphism in Java

Polymorphism in Java is a concept by which we can perform a single action in different ways. Polymorphism is derived from 2 Greek words: poly and morphs. The word “poly” means many and “morphs” means forms. So polymorphism means many forms.

We have two types of Polymorphism:
1. Compile Time Polymorphism/Method OverLoading
2. Run-Time Polymorphism/Method Overriding

Polymorphism in Java


28. Abstraction in Java

Abstraction in Java, Java Object-Oriented Programming, Abstract Class, Abstract Methods, Java Interfaces, and Inheriting Abstract classes.

Abstract classes and Abstract methods:

• An abstract class is a class that is declared with abstract keyword.
• An abstract method is a method that is declared without implementation.
• An abstract class may or may not have all abstract methods. Some of them can be concrete methods
• A method defined abstract must always be redefined in the subclass, thus making overriding compulsory OR either make the subclass itself abstract.
• An abstract class can have parameterized constructors and the default constructor is always present in an abstract class.

Abstraction in Java


Types of Output in Java

Types of Output in Java Programming, Value bases Result in Java, Boolean Result in Java, Constant based Result in Java, and Dynamic Result in Java.

Java Input and Output Operations

Read user input
Read data from files
Write program output on the console
Write data or output in files

Types of Output in Java Programming


Selenium Online Training

Java Programming Language Syllabus

Java Step by Step Videos

Follow me on social media:

44 thoughts on “Java Tutorial”

Leave a Comment