Java int type literals Question 1

Question

What is the output of the following code?

public class Main {
  public static void main(String[] args) {
    System.out.println(0B1111); 

    System.out.println(07777); 

    System.out.println(0XFFFF); 
  }
}


15
4095
65535

Note

By default, an integer literal is a decimal integer number.

To denote a binary integer literal, use a leading 0b or 0B (zero B).

To denote an octal integer literal, use a leading 0 (zero).

To denote a hexadecimal integer literal, use a leading 0x or 0X (zero X).

public class Main {
  public static void main(String[] args) {
    System.out.println(0B1111); /*ww  w . ja  va2 s.co  m*/

    System.out.println(07777); 

    System.out.println(0XFFFF); 
  }
}



PreviousNext

Related