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

Can constructor return value?

973


What is unicode datatype?

970


What does file separator do in java?

1021


How can we access some class in another class in java?

999


What is a blocking method in Java?

1250


what is the purpose of "virtual"?

1088


Can private method static?

930


What is java reflection api?

1024


What is boolean example?

977


What is java in detail?

1073


What is string data type?

979


Why collection doesn’t extend cloneable and serializable interfaces?

1110


How does varargs work in java?

1103


What do you mean by exception handling in Java?

1299


What are advantages and disadvantages of OOPs?

1140