ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

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
تم إضافة السؤال من قبل Imranullah Khan , Full Stack Developer , GoDigital Inc
تاريخ النشر: 2013/12/29
SUMITH V S
من قبل 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
من قبل Mohammed Shareefuddin , Project Associate , Cognizant Technology Solutions

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

Basharat Irshad
من قبل 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

المزيد من الأسئلة المماثلة

هل تحتاج لمساعدة في كتابة سيرة ذاتية تحتوي على الكلمات الدلالية التي يبحث عنها أصحاب العمل؟