Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Can we add two byte variables and assign the result to a
byte variable ?
b=b1+b2 where b,b1,b2 are byte types

Answer Posted / ashish ranjan

No We cannot add two byte variables directly. The reason behind is the operator '+' is used to perform integer operation. so the variables are automatically promoted to the integer when we perform any arithmetic operation.

so we need to typecast the variables

b= (byte)(b1 + b2);

Is This Answer Correct ?    15 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What does jenkins do?

863


What is byte [] in java?

956


What is the difference between int and integer in java?

983


How do you compare characters in java?

919


What is java string pool?

947


What is a layout manager and what are different types of layout managers available in java awt?

1199


How do you define a parameter?

983


What is class??

1172


Why multiple inheritance is not supported by java?

928


what do you mean by classloader in java?

974


What is java console application?

943


Explain the meaning of java applet.

1016


What is final, finally, finalize?

1024


Can you declare the main method as final?

955


What is null statement?

944