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
When will you define a method as static in Java?
What is a flag value?
Considering notepad/ie or any other thing as process, what will happen if you start notepad or ie 3 times? Where 3 processes are started or 3 threads are started?
What are keywords and reserved words in java?
How many digits can a float hold?
What is your platform?s default character encoding and how to know this?
What do you understand by abstract classes?
Why vector class is used?
What is native code?
What is the difference between iterator and enumeration ?
What are the different types of inheritance in java?
According to java operator precedence, which operator is considered to be with highest precedence?
Which object oriented concept is achieved by using overloading and overriding?
What is the length of a string?
write a program that list all permutations of ABCDEF in which A appears before B?