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

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

متابعة

Can u differentiate between (1). byte b=5; int a=6; a = (int)(a+b) and (2). byte b =5; int a=6; a += b?

user-image
تم إضافة السؤال من قبل himanshu mittal
تاريخ النشر: 2013/06/29
Balaji Thiagarajan
من قبل Balaji Thiagarajan , Solutions Architect , InfinitePL

1.
byte b=5 (can hold upto127 without casting) int a=6 (all integer literals are by default int) a= a+b -> will always be int even if you dont cast it.
but b=a+b -> here you will need explicit casting like b=(byte)(a+b) 2.
byte b=5; int a=6; a+=b; -> Automatic casting done by compiler so even b+=a will compile in this case.

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

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