0% found this document useful (0 votes)
7 views11 pages

Features of Java

Java is a portable, simple, and secure programming language with key features such as being object-oriented, robust, and platform-independent. It supports multithreading, high performance through just-in-time compilation, and provides a variety of data types including primitive and non-primitive types. Identifiers in Java must follow specific rules and are case sensitive, allowing for clear naming of classes, methods, and variables.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views11 pages

Features of Java

Java is a portable, simple, and secure programming language with key features such as being object-oriented, robust, and platform-independent. It supports multithreading, high performance through just-in-time compilation, and provides a variety of data types including primitive and non-primitive types. Identifiers in Java must follow specific rules and are case sensitive, allowing for clear naming of classes, methods, and variables.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Features of Java

The primary objective of Java programming language creation was to


make it portable, simple and secure programming language. Apart from
this, there are also some excellent features which play an important role
in the popularity of this language. The features of Java are also known as
Java buzzwords.

A list of the most important features of the Java language is given


below.

1. Simple
2. Object-Oriented
3. Portable
4. Platform independent
5. Secured
6. Robust
7. Architecture neutral
8. Interpreted
9. High Performance
10. Multithreaded
11. Distributed
12. Dynamic
1) Simple

Java is easy to learn and its syntax is quite simple, clean and easy to
[Link] confusing and ambiguous concepts of C++ are either left
out in Java or they have been re-implemented in a cleaner way.

Eg : Pointers and Operator Overloading are not there in java but were an
important part of C++.
2) Object Oriented

In java, everything is an object which has some data and behaviour. Java
can be easily extended as it is based on Object Model. Following are
some basic concept of OOP's.

i. Object
ii. Class
iii. Inheritance
iv. Polymorphism
v. Abstraction
vi. Encapsulation

3) Robust

Java makes an effort to eliminate error prone codes by emphasizing


mainly on compile time error checking and runtime checking. But the
main areas which Java improved were Memory Management and
mishandled Exceptions by introducing automatic Garbage
Collector and Exception Handling.

4) Platform Independent

Unlike other programming languages such as C, C++ etc which are


compiled into platform specific machines. Java is guaranteed to be
write-once, run-anywhere language.

On compilation Java program is compiled into bytecode. This bytecode


is platform independent and can be run on any machine, plus this
bytecode format also provide security. Any machine with Java Runtime
Environment can run Java Programs.
5) Secure

When it comes to security, Java is always the first choice. With java
secure features it enable us to develop virus free, temper free system.
Java program always runs in Java runtime environment with almost null
interaction with system OS, hence it is more secure.

6) Multi Threading

Java multithreading feature makes it possible to write program that can


do many tasks simultaneously. Benefit of multithreading is that it
utilizes same memory and other resources to execute multiple threads at
the same time, like While typing, grammatical errors are checked along.

7) Architectural Neutral

Compiler generates bytecodes, which have nothing to do with a


particular computer architecture, hence a Java program is easy to
intrepret on any machine.
8) Portable

Java Byte code can be carried to any platform. No implementation


dependent features. Everything related to storage is predefined, example:
size of primitive data types

9) High Performance

Java is an interpreted language, so it will never be as fast as a compiled


language like C or C++. But, Java enables high performance with the
use of just-in-time compiler.

10) Distributed

Java is also a distributed language. Programs can be designed to run on


computer networks. Java has a special class library for communicating
using TCP/IP protocols. Creating network connections is very much
easy in Java as compared to C/C++.

Data Types in Java

Data types specify the different sizes and values that can be stored in the
variable. There are two types of data types in Java:

1. Primitive data types: The primitive data types include boolean,


char, byte, short, int, long, float and double.
2. Non-primitive data types: The non-primitive data types
include Classes, Interfaces, and Arrays.

Java Primitive Data Types

In Java language, primitive data types are the building blocks of data
manipulation. These are the most basic data types available in Java
language.
Java is a statically-typed programming language. It means,
all variables must be declared before its use. That is why we need to
declare variable's type and name.

There are 8 types of primitive data types:

o boolean data type


o byte data type
o char data type
o short data type
o int data type
o long data type
o float data type
o double data type
Boolean Data Type

The Boolean data type is used to store only two possible values: true and
false. This data type is used for simple flags that track true/false
conditions.

The Boolean data type specifies one bit of information, but its "size"
can't be defined precisely.

Example:

1. Boolean one = false


Byte Data Type

The byte data type is an example of primitive data type. It isan 8-bit
signed two's complement integer. Its value-range lies between -128 to
127 (inclusive). Its minimum value is -128 and maximum value is 127.
Its default value is 0.
The byte data type is used to save memory in large arrays where the
memory savings is most required. It saves space because a byte is 4
times smaller than an integer. It can also be used in place of "int" data
type.

Example:

1. byte a = 10, byte b = -20


Short Data Type

The short data type is a 16-bit signed two's complement integer. Its
value-range lies between -32,768 to 32,767 (inclusive). Its minimum
value is -32,768 and maximum value is 32,767. Its default value is 0.

The short data type can also be used to save memory just like byte data
type. A short data type is 2 times smaller than an integer.

Example:

1. short s = 10000, short r = -5000


Int Data Type

The int data type is a 32-bit signed two's complement integer. Its value-
range lies between - 2,147,483,648 (-2^31) to 2,147,483,647 (2^31 -1)
(inclusive). Its minimum value is - 2,147,483,648and maximum value is
2,147,483,647. Its default value is 0.

The int data type is generally used as a default data type for integral
values unless if there is no problem about memory.

Example:

1. int a = 100000, int b = -200000


Long Data Type

The long data type is a 64-bit two's complement integer. Its value-range
lies between -9,223,372,036,854,775,808(-2^63) to
9,223,372,036,854,775,807(2^63 -1)(inclusive). Its minimum value is -
9,223,372,036,854,775,808and maximum value is
9,223,372,036,854,775,807. Its default value is 0. The long data type is
used when you need a range of values more than those provided by int.

Example:

1. long a = 100000L, long b = -200000L


Float Data Type

The float data type is a single-precision 32-bit IEEE 754 floating


[Link] value range is unlimited. It is recommended to use a float
(instead of double) if you need to save memory in large arrays of
floating point numbers. The float data type should never be used for
precise values, such as currency. Its default value is 0.0F.

Example:

1. float f1 = 234.5f
Double Data Type

The double data type is a double-precision 64-bit IEEE 754 floating


point. Its value range is unlimited. The double data type is generally
used for decimal values just like float. The double data type also should
never be used for precise values, such as currency. Its default value is
0.0d.

Example:

1. double d1 = 12.3
Char Data Type

The char data type is a single 16-bit Unicode character. Its value-range
lies between '\u0000' (or 0) to '\uffff' (or 65,535 inclusive).The char data
type is used to store characters.

Example:

1. char letterA = 'A'

2) Non-Primitive(Reference) Data type

A reference data type is used to refer to an object. A reference variable is


declare to be of specific and that type can never be change.

For example: String str, here str is a reference variable of type String.
String is a class in Java. We will talk a lot more about reference data
type later in Classes and Object lesson.

Reference type are used to hold reference of an object. Object can be


instance of any class or entity.

In object oriented system, we deal with object that stores properties. To


refer those objects we use reference types.

Identifiers in Java

All Java components require names. Name used for classes,


methods, interfaces and variables are called Identifier.
Identifier must follow some rules. Here are the rules:

 All identifiers must start with either a letter( a to z or A


to Z ) or currency character($) or an underscore.
 After the first character, an identifier can have any
combination of characters.
 Java keywords cannot be used as an identifier.
 Identifiers in Java are case sensitive, foo and Foo are two
different identifiers.
Some valid identifiers are: int a, class Car, float
amount etc.

You might also like