Java Introduction - The Coding Shala

Home >> Learn Java >> Java Introduction

Java Introduction

Java is an Object-Oriented Programming(OOP) language rather than process-oriented. Java is a multi-purpose and cross-platform programming language developed by Sun Microsystems. Java is simple and easy to use and Java is platform-independent language so being described as a "Write once, run anywhere".  Whenever we compile the Java code it produces bytecode. and Java Virtual Machine (JVM) works as an interpreter for the bytecode. 
Java Introduction - The Coding Shala

The process-oriented programs contain a series of linear steps. C is a Procedural Programming language. Object-oriented programming organizes a program around its data that is an object and a set of the well-defined interface to that data.

Abstraction is a necessary part of object-oriented programming language. Abstraction is the process to hide certain details and only shows the essential features of the object. Encapsulation, Inheritance, and polymorphism are the main principles of OOP language. Encapsulation is the mechanism that binds code and the data together and prevents it from misuse. we can think encapsulation as a protective wrapper that keeps safe the code and data from being accessed by the other code defined outside the wrapper. In Java, Class is the basis of encapsulation. 

A class defines the structure and behavior (data and code) basically class is a blueprint. The class contains objects, each object of a given class contains the behavior defined by the class. Objects are referred to as instances of a class. whenever we create a class, we specify the code and data(like variables, methods) in it all these elements called members of the class.

Inheritance is a process by which one class can acquire the properties and methods of another class.  A class derived from another class is called subclass or child class, whereas the class from which a subclass is derived is called a superclass.

Polymorphism means "many forms". Polymorphism in Java is a concept by which we can perform a single action in different ways. In Java "compile-time and runtime polymorphism" is there.



We will discuss all these terms and topics in detail in later topics. This is just a brief introduction.


Block of Code

If two or more statements are grouped together between the opening and closing curly braces then its called blocks of code or code blocks. For example- 

for(int i=0;i<5;i++){ //begin a block
//code inside for loop
System.out.println("Value of i is: " + i);
}//end of block

Whitespace

In Java, whitespace is space, tab or newline. In Java, we do not need to follow any indentation rules. Java programs can be written all on one line or many.

Identifiers

In Java, identifiers are class names, method names, and variable names. Identifiers can have letters, numbers, underscore and dollar sign characters. There are some rules for identifiers like they must not start with a number and Java is case-sensitive so Var is different identifier than var.

Some examples of valid identifier are - 
Count
temp
var4
$test
var_one

some examples of invalid identifiers are-
1count
count-one
not/this

Literals

In Java, Literals are constant values. For examples 10, 34, 'X', 'Y', 22.22, "This is also" all are literals.

Comments

Comments are ignored by Java compilers. They used to describe the code and other useful information. There are single-line comments and multi-line comments in Java.

Java Keywords

In Java, there are currently 50 keywords that are reserved. These keywords cannot be used as names of classes, variables or methods. The following are the list of keywords - 
Java Keywords - The Coding Shala
The keyword const and goto are reserved but not used in java. In Java, true, false, and null are also reserved. 



Other Posts You May Like
Please leave a comment below if you like this post or found some error, it will help me to improve my content.

Comments

Popular Posts from this Blog

Shell Script to find sum, product and average of given numbers - The Coding Shala

Single Number 3 LeetCode Solution - The Coding Shala

LeetCode - Number of Good Pairs Solution - The Coding Shala

Shell Script to Create a Simple Calculator - The Coding Shala

Java Method Overloading - The Coding Shala