Communiquez avec les autres et partagez vos connaissances professionnelles

Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.

Suivre

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 ajoutée par Imranullah Khan , Full Stack Developer , GoDigital Inc
Date de publication: 2013/12/29
SUMITH V S
par 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
par Mohammed Shareefuddin , Project Associate , Cognizant Technology Solutions

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

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

Default value is "0" for byte data type

Utilisateur supprimé
par Utilisateur supprimé

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

 

Utilisateur supprimé
par Utilisateur supprimé

Its "0"

Utilisateur supprimé
par Utilisateur supprimé

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

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

Its0

More Questions Like This