Determine the network address

  • 24
  • Locked
1) The IP address and subnet mask are given. You need to calculate the network address: implement the getNetAddress method. Use the bitwise AND operator. Example: IP address: 11000000 10101000 00000001 00000010 ( Subnet mask: 11111111 11111111 11111110 00000000 (
You can't complete this task, because you're not signed in.
Comments (6)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Justin Smith
Level 38 , Greenfield, USA, United States
6 December 2021, 03:17
Tough task but very interesting. This topic is definitely not how I expected to start a section called "Multithreading".
Level 29 , Stockholm, Sweden
5 January 2021, 21:57
Integer.toBinaryString(256 + (int) aByte); Why need to make addition here?
Level 41
9 March 2021, 15:09
I am assuming because byte is up to 127 (inclusive) so you would lose some numbers from 192 but I don't understand the use of 256 here. Why 256 and not any other number?
Level 41
9 March 2021, 15:33
Please check Guada's answer here:
Justin Smith
Level 38 , Greenfield, USA, United States
6 December 2021, 03:17
It's filling the first 8 digits with 1s so that leading 0s aren't cut off. For example, if your byte is: 00000101, using toBinaryString will create "101" as the string. To pass validation, all 8 digits must be included. 256 + (int) aByte causes the toBinaryString to output 1111111100000101, so the 0s aren't lost. It's a lot simpler than the method I used, which use String.format and "%8s" to force it to be at least 8 characters long, then replaceAll to replace the spaces with 0s.
yehuda b
Level 23 , Beersheba, Israel
22 December 2020, 13:54
To get a string representation of the binary digits of each byte, see