In Java:
I have a 32-bit number given to me in hexadecimal form. I'm given a specific byte number (0-3, 0 for least-significant byte) and told that I need to replace that byte with another byte also given to me in hexadecimal form. Ex: 32-bit number 0xAAA5BBC6, replace byte 1 with 0x17 to get 0xAAA517C6.
I can't use any casting, multiplication, addition, subtraction, or conditionals. I cannot write any helper methods, or call any other method from this or another file to implement any method. Additionally, this has to be written in one line of code.
I believe I should be using masking, but I can't figure out where to start. Given a byte number, how can I change all 8 bits. Toggling one off or on is easy, but toggling all 8 bits to be a certain value?