articles

Home / DeveloperSection / Articles / Java fundamental

Java fundamental

Anonymous User1422 31-Aug-2018

JAVA FUNDAMENTALS

IDENTIFIERS:

In simple word identifier can be said to a name of a class, method, variable or label.it is mainly used for identification purpose.

For example:

 class exmp{

          Public void static main( String[ ] args ){

                          int x=10;

}

}

In above identifiers are

• Test

• Main

• String

• args

• x

Rules for defining identifiers:

• Characters which are allowed are alphanumeric ([A-Z] [a-z] [0-9]) and symbols $ and _ are allowed.

• Identifiers should not start with any digit [0-9].

• Identifiers are case-sensitive.

• No length limit for the identifier.

• Reserved words cannot be used as an identifier in java.

RESERVED WORDS:

Reserved words are used to represent certain functionalities defined by that language.

These can be divided into two parts.

• Keywords

• Reserved literals

DATA TYPES:

• Numeric data type: it is used to represent numbers.it can be divide into two type:-

1. Integral types

2. Floating types

 1.Integral type: it is used to represent whole no.it can be categorized into four types:

• byte

• short

• int

• long

               byte:

          Size: 8 bits

          Range: -128 …. 127

The most significant bit is called sign bit.0 means +ve 1 means –ve value.

+ve numbers represented directly into the memory whereas –ve numbers are represented in 2’s complement form.

For example:

                      byte b=100;

             short:

                           Size: 16 bits

                            Range:-215 to 215[-32768 to 32767]

                    The most rarely used data type in java is short.

                     For example:

                                 short s=-32768;

              int:

                           Size: 32 bits

                           Range: -231 to 231

                       The most commonly used data type is int.

                        In java size of int is 4byte irrespective of any platform.

             long:

                            Size: 64 bits

                            Range: -263 to 263

                         Whenever int is not enough to hold big value then we use long.

2.Floating type: used to represent real numbers.

It can be categorized into two types:

1. float

2. double

           float:

                       Size:4 bytes

                        Range:-3.4e38 to 3.4e38

             float follows single precision and if we want 5 to 6 decimal accuracy the we should go for float.

             double:

                        Size:8 bytes

                        Range:-1.7e308 to 1.7e308

                double follows double precision and if we want 14 to 15 decimal accuracy then we should go for double.

• Boolean data type: it is a type whose value is either true or false

                     Size: 1 bit

                     Range: not applicable

• Char data type: the character type whose values are 16 bit Unicode characters.

                             Size: 4 bytes

                             Range:0 to 65535



Updated 04-Mar-2020
I am a content writter !

Leave Comment

Comments

Liked By