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 / m. abhishek

yes, but u require type casting because the the binary
operation in java should atleast returns Integer values


example :
byte a=12;
byte b=23;
// byte c=a+b; //Not OK,bcoz a+b is an int value
int c=(byte)a+b; // OK

Is This Answer Correct ?    34 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How many bytes is double?

549


What is java algorithm?

524


Why is method overloading not possible by changing the return type in java?

594


Can Exception handling we can handle multiple catch blocks?

647


What is a nested list?

524






What is the meaning of nullable?

578


Why is java so popular?

639


I want to persist data of objects for later use. What’s the best approach to do so?

507


How does java enable high performance?

694


What are multiple inheritances? Is it supported by java?

467


How do you escape a string?

508


What is map java?

519


What is difference between static and final?

561


What is the final blank variable?

592


What are the types of collections in java?

541