please explain this code

public class B {

public int add()
{
return 011;
}
public static void main(String[] args)
{
B b1=new B();

System.out.println(b1.add());
}

}



the output is 9, how it will comes....

Replies

  • Omesh3
    Omesh3
    011 is octal for 9. Java interprets numbers starting with "0" as octal numbers (numbers with base 8). Remove the leading zero and you will get a different print out.😁

    0-9 in base 8 (octal):
    0 = 000
    1 = 001
    2 = 002
    3 = 003
    4 = 004
    5 = 005
    6 = 006
    7 = 007
    8 = 010
    9 = 011

You are reading an archived discussion.

Related Posts

A TYPICAL FILMY SCENE...: a person gets hurt in an accident and people rush him to the nearby hospital and try to get him admitted quickly, but the doctors refuse...
A conductor in (x-y) plane and having lenth 1m is moving with velocity V=(2i+3j+k)m/sec.Magnetic flux desity B=(i+2j)wb/m2.Potential difference at the end of the conductor is(Explain your answer) i)0 ii)4.88V iii)root6...
hey guys, i have started this thread in the hope of helping you to develop your strengths and work on your weaknesses and at the same time have fun..... well...
Soory i'll post it again due to some technical problems
Hi😎 I would like to know the internal process behind the restoring of data in computer.. After deleting everything we can restore it back.how it is done internally?? Thanks