Data types and Access modifiers. In English

                                   Data type and Access modifiers








Content 

1.What is a data type?

2.Data types

3.Number systems

4.Access modifiers


1.What is a data type?

The different types of data that can be stored are called data types.

2.Data types

Data types are divided into two categories.

             1.Primitive data types

             2.Non - primitive data types

Primitive Data Types

A primitive data type specifies the size and type of variable values.

There are eight primitive data types in Java.

Numerical data types: - 1. byte (Byte)

                                           2. short (Short)

                                           3. int (Integer)

                                           4. long (Long)

                                           5. float (Float)

                                           6. double (Double)

True/False(binary-1/0): -7. boolean (Boolean)

                                           8. char (Character)

                                             

String is a class. But string is used as a data type in Java.


3.Number systems

1.Binary number system

   Use 2 digits 0 and 1. Also called as based 2 number system. Each binary digit is also called a bit. 

    Ex: - 110112

 2.Decimal number system

    The decimal number system is the standard system for denoting integer and non-integer numbers. Also called as based 10 number system.

    Ex: - 33410

3.Octal number system

   Use eight digits. 0,1,2,3,4,5,6,7. Aso called based 8 number system.

    Ex: - 125078


4.Hexadecimal number system

    Use 10 digits and 6 letters. 0,1,2,3,4,5,6,7,8,9, A, B, C, D, E, F. Letters represent numbers starting from A=10, B=11, C=12, D=13, E=14, F=15. Also called as based 16 number system.

     Ex: - 56EA16


  



                                 bit 8          = byte 1

                                 byte 1024 = kb 1

                                 kb 1024    = mb 1

                                 mb 1024   = gb 1

                                 gb 1024    = terra 1

                                 Peta byte, Jeta byte, Zeta byte



 

Data typeSizeRangeDefault value
booleanbit 1True/FalseFALSE
bytebit 8-128 to 1270
shortbit 16-32768 to 327670
intbit 32-2147483648 to 21474836470
longbit 64-263 to 263 -10
floatbit 32-2147483648 to 21474836470.0
doublebit 64long range0.0
charbit 16any character (Unicode)0 (Unicode)


               


                                      string a = "Nimeshi"

                                      string b = "456" X

                             int c = "123"

4.Access modifiers

Access modifiers are used to modify the security given to access classes, variables and methods.        

There are four types of access modifiers.

1.Public - Anyone can use.

2.Protected - The code is accessible in the class, package and sub classes.

3.Private - The code is only accessible in class.

4.Default - The code is only accessible in class and package.


              (class, method, variable)

     public class Nimeshi {

     }

     protected class Nimeshi {

     }

     private class Nimeshi {

     }

     class Nimeshi { }


      public void abc ( ) {

      }

      private void abc ( ) {

      }

      void abc ( ) {

      }






Comments

Popular posts from this blog

Lambda expression in Java. In English

Loops in Java. In English

Conditions in java. In English