### Question:
IPv4 implements Writable, Comparable<IPv4> { public IPv4 and(IPv4 other) { byte[] res = new byte[4]; byte[] obytes = other.getBytes(); for (int i = 0; i < 4; i++) { res[i] = (byte)(this.ipBytes[i] & obytes[i]); } return new IPv4(res); } IPv4();  IPv4(byte[] bytes);  IPv4(String ipAddress); static IPv4 getSubnetMask(int len); void set(String ipAddress); void set(byte[] bytes); byte[] getBytes(); boolean matchSubnet(String addr); boolean matchGeoIP(/* country code */); IPv4 and(IPv4 other); @Override boolean equals(Object o); @Override int compareTo(IPv4 o); @Override String toString(); @Override int hashCode(); @Override void readFields(DataInput in); @Override void write(DataOutput out);  }### Answer:
@Test public final void testAnd() throws InvalidAddressException { IPv4 ip1 = new IPv4("163.152.23.223"); IPv4 ip2 = new IPv4("255.255.255.0"); IPv4 ip3 = new IPv4("255.0.0.0"); assertEquals(new IPv4("163.152.23.0"), ip1.and(ip2)); assertFalse(ip1.and(ip2).equals(new IPv4("163.152.0.0"))); assertTrue(ip1.and(ip3).equals(new IPv4("163.0.0.0"))); }