Java Numeric Data Type

Java Data Type
1. Java is strongly typed programming language
e.g. int x = 10.6; Wrong
Boolean a = 0; Wrong
2. Java is not considered as pure object-oriented language as it used primitive data types which are not an object. Also, operator overloading and multiple inheritances are not supported.

Watch here:

Primitive data types
1. Numeric Data Type
2. Non-Numeric Data Type
a. char
b. boolean

Numeric Data Type
1. Integral Data Type
a. byte ( 8 bit) (MAX_VALUE = +127 , MIN_VALUE = -128) (RANGE = -128 to +127)
e.g. byte b = 127 , byte b = 128 (Incorrect), byte c = 10.5 (incorrect), byte d = true
* If we want to handle data in terms of streams then we use byte

b. short (2 bytes – 16 bits) (RANGE – -2^15 to 2^15-1) (-32768 to 32767)
* No one is used short data type
e.g. short s = 32767, short s = 32768 (wrong)
* Short is used for a 16-bit processor like 8085, 8086 because of reading and writing process is easy and efficient. But now they are outdated so no one is using short data type.

c. int (4 bytes – 32 bits) (Range -2^31 to 2^31-1) (-2147483648 to 2147483647)
* Most common data type is int
e.g. int x = 2147483647, int x = 2147483648 (wrong), int x = 2147483648L

d. long ( 8 bytes – 64 bits) (Range -2^63 to 2^63-1)
* If we want to count all characters present in a big file then we use long

Java Identifier

Identifiers are the names of variables, methods, classes, packages, and interfaces. Unlike liberals, they are not the things themselves, just ways of referring to them. In the HelloWorld program, HelloWorld, String, args, main and println are identifiers.

Rules:

1. Identifier created by below convention only
a. a to z
b. A to Z
c. 0 to 9
d. $
e. _ (underscore)

2. The identifier should not start with a digit. e.g. 123Hello is an invalid class whereas Hello123 is valid class.
3. Java Identifier is case sensitive.
4. There is no length limit for Java Identifier.
5. We can’t use reserved words as Identifier.
6. All predefined class and interface names we can use as Identifiers.

Java Access Modifiers

The access modifiers in java specify accessibility (scope) of a data member, method, constructor or class.

There are 4 types of java access modifiers:

private
default
protected
public

1. The private access modifier is accessible only within the class.
2. The default modifier is accessible only within the package.
3. The protected access modifier is accessible within the package and outside the package but through inheritance only.
4. The public access modifier is accessible everywhere. It has the widest scope among all other modifiers.

Please email us at online.nimit@gmail.com if you need any further information.