Java Program to Calculate Sum of Two Byte Values Using Type Casting Last Updated : 11 Nov, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report The addition of two-byte values in java is the same as normal integer addition. The byte data type is 8-bit signed two's complement integer. It has a minimum value of -128 and a maximum value of 127 (inclusive). The Sum of two-byte values might cross the given limit of byte, this condition can be handled using storing the sum of two-byte numbers in an integer variable. Example: Input: firstByte = 10, secondByte = 23 Output: Sum = 33 Input: firstByte = 10, secondByte = 23 Output: Sum = 33 Type Casting: Typecasting is simply known as cast one data type, into another data type. For example, in this program, Byte values are cast into an integer. Approach: Declare and initialize the two-byte variable.Declare one int variable.Store the sum of the two-byte numbers into an int variable. Below is the implementation of the above approach Java // Java Program to Calculate Sum of // Two Byte Values Using Type Casting public class GFG { public static void main(String[] args) { // create two variable of byte type byte firstByte = 113; byte secondByte = 123; // create int variable to store result int sum; sum = firstByte + secondByte; System.out.println("sum = " + sum); } } Outputsum = 236 Comment More infoAdvertise with us Next Article Java Program to Convert Binary String to Decimal Using Wrapper Class M mukulsomukesh Follow Improve Article Tags : Java Java Programs Practice Tags : Java Similar Reads Java Program to Convert Binary String to Decimal Using Wrapper Class Given a binary string as input, we need to write a program to convert the given binary string into its equivalent decimal number. Examples: Input : 1111 Output : 15 Input : 1001101 Output : 77 Input : 1101 Output : 13 The idea is to extract each character of a given binary string using charAt() and 2 min read Java Program to Convert Char to Byte Given a char in Java, the task is to write a Java program that converts this char into Byte. Examples: Input: ch = 'A' Output: 65 Input: ch = 'B' Output 66 In Java, char is a primitive data type and it is used to declare characters. It has the capability to hold 16-bit unsigned Unicode characters. T 3 min read Convert Long Values into Byte Using Explicit Casting in Java In Java, a byte can contain only values from -128 to 127, if we try to cast a long value above or below the limits of the byte then there will be a precision loss. 1. byte: The byte data type is an 8-bit signed twoâs complement integer. Syntax: byte varName; // Default value 0 Values: 1 byte (8 bits 2 min read Java Program to Add Two numbers Without using Arithmetic Operator Here, we need to write a function that returns the sum of two stated integers. And the function must not utilize any of the arithmetic operators such as +, ++, â, -, .. Etc.). It will be a very basic elementary level program to compute the sum by simply using the '+' operator and thereby simply prin 2 min read Java Program to Convert Integer Values into Binary Given an integer in Java, your task is to write a Java program to convert this given integer into a binary number. Example: Input: = 45 Output: = 101101 Input: = 32 Output: = 100000 Integers: Integers are numbers whose base value is 10. The Integer or int data type is a 32-bit signed twoâs complemen 4 min read How to Get Size, Minimum, and Maximum Value of Data Types in Java? The size of a data type is given by (name of datatype).SIZE. The maximum value that it can store is given by (Name of data type).MAX_VALUE. The minimum value that it can store is given by (Name of data type).MIN_VALUE. Always write first word of data type in capital. Example: 1. If you want to print 2 min read Like