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

Is upper case in java?

1010


Explain the differences between static and dynamic variables?

1202


What is the difference between declaration and definition in java?

1158


What is a databasemetadata?

994


What is difference between static and final?

1135


What are java annotations?

1227


What is a parameter in simple terms?

1071


What is the use of java?

1013


Differentiate between nested and inner class in java.

1050


What is java util hashmap?

1035


What is meant by 'Class access modifiers'?

1093


what is thread? What are the high-level thread states? : Java thread

1329


Do we need to manually write Copy Constructor?

1090


What is nested class?

1054


Give us a program to check for parenthesis matching using stack.

1050