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 about static nested classes in java?

1134


What does the “static” keyword mean? Can you override private or static method in java?

1093


What is the default value of byte datatype in java?

934


What is a cup of java?

1010


What is a jagged array in java?

1106


What is the purpose of skeleton and stub?

1231


Explain throw keyword in java?

1042


How can we make a class singleton?

1062


Why are parameters used in functions?

1013


What is an enumeration?

1061


What is structure of java heap? What is perm gen space in heap?

1122


What is the difference between super class & sub class?

1184


Is array passed by reference in java?

1025


What is the file type?

1017


What is the default size of set in java?

951