Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

What is the default value for byte data type in Java?

As every data type has its default value after initialization so I would like to know the default value for byte data type in Java.

user-image
Question added by Imranullah Khan , Full Stack Developer , GoDigital Inc
Date Posted: 2013/12/29
SUMITH V S
by SUMITH V S , Operations Coordinator , Christian Dior Couture Middle East FZE

byte:
  • Byte data type is an8-bit signed two's complement integer.

  • Minimum value is -128 (-2^7)

  • Maximum value is127 (inclusive)(2^7 -1)

  • Default value is0

  • Byte data type is used to save space in large arrays, mainly in place of integers, since a byte is four times smaller than an int.

  • Example: byte a =100 , byte b = -50

Mohammed Shareefuddin
by Mohammed Shareefuddin , Project Associate , Cognizant Technology Solutions

Default value of byte data type in java is "0" 

Basharat Irshad
by Basharat Irshad , HSE Officer , Eastern International L.L.C

Default value is "0" for byte data type

There are two types of data type in java or in OO world which is primitive and objects the difference is primitive data types store in stack, and object are stored in memories so byte x; when you declare since it’s a primitive data type it’s store in stack, so it’s basically x is a pointer to the stack which is empty when you try to run exception will pop up but when you think technically it’s x point to empty space in the stack it’s the same us objects

 

0 is default value for all integer data types i.e. byte, short, int long

Muhammad Zafar Ayaz Khan
by Muhammad Zafar Ayaz Khan , Technical Team Lead , Optimal Solutions Karachi

Its0

More Questions Like This

Do you need help in adding the right keywords to your CV? Let our CV writing experts help you.