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
Is upper case in java?
Explain the differences between static and dynamic variables?
What is the difference between declaration and definition in java?
What is a databasemetadata?
What is difference between static and final?
What are java annotations?
What is a parameter in simple terms?
What is the use of java?
Differentiate between nested and inner class in java.
What is java util hashmap?
What is meant by 'Class access modifiers'?
what is thread? What are the high-level thread states? : Java thread
Do we need to manually write Copy Constructor?
What is nested class?
Give us a program to check for parenthesis matching using stack.