What is the output of this program?
class Literal23
{
public static void main(String[] args)
{
char c=0b1000001;
System.out.println(c);
}
}
/*
Output:- A
Explanation:- Until java 1.6 version we can specify literal value only for decimal,octal,hexadecimal
literals but from 1.7 version onwards we can specify literal value even in binary form also.
but literal value should be prefixed with "0b" or "0B" and allowed digits are only 0 and 1.
*/
{
public static void main(String[] args)
{
char c=0b1000001;
System.out.println(c);
}
}
/*
Output:- A
Explanation:- Until java 1.6 version we can specify literal value only for decimal,octal,hexadecimal
literals but from 1.7 version onwards we can specify literal value even in binary form also.
but literal value should be prefixed with "0b" or "0B" and allowed digits are only 0 and 1.
*/
0 comments: