Given:
What is the result?
Given:
What is the result?
The method new Main().print(0b1101_1010) calls the print method with the binary value 0b1101_1010, which is 218 in decimal. In Java, a binary literal prefixed with 0b is considered an integer. However, 218 exceeds the range of a byte type (which is -128 to 127) and therefore fits within the range of an int. But since both int and long can accommodate 218, Java will prefer the more specific method when possible. Thus, it will choose print(long j) because method resolution in Java chooses the narrowest possible type when an exact match isn't found, leading to the result 'there'.
package q10; public class Main { void print(int i) { System.out.println("hello"); } void print(long j) { System.out.println("there"); } public static void main(String[] args) { new Main().print(0b1101_1010); } } // Result: // hello
C is the correct answer
C is correct answer
Auto promote to int C is correct