What will be the result of the expression 7 ^ 3 in Java?
- 0
- 10
- 3
- 4
In Java, the ^ operator is the bitwise XOR operator. It performs a bitwise XOR operation on the binary representations of the two operands. In this case, 7 in binary is 0111, and 3 in binary is 0011. Performing XOR, we get 0100, which is 4 in decimal. So, the result is 4.
Loading...
Related Quiz
- Consider a scenario where a very large number of string concatenation operations are being performed in a single-threaded application. Which class would be appropriate to use for string manipulation, and why?
- Which of the following data types can store a null value in Java?
- Consider building a microservice handling requests from various clients and other microservices. How would you implement socket programming for non-blocking, asynchronous I/O and high throughput?
- The Character class in Java is used to wrap a value of the primitive data type ________.
- How does intrinsic locking in synchronized methods/blocks ensure thread safety?