### Question:
Chromosome implements Comparable<Chromosome> { public Chromosome mutate() { char[] arr = gene.toCharArray(); int idx = rand.nextInt(arr.length); int delta = (rand.nextInt() % 90) + 32; arr[idx] = (char) ((arr[idx] + delta) % 122); return new Chromosome(String.valueOf(arr)); } Chromosome(String gene); String getGene(); int getFitness(); Chromosome mutate(); Chromosome[] mate(Chromosome mate); @Override int compareTo(Chromosome c); @Override boolean equals(Object o); @Override int hashCode();  }### Answer:
@Test public void testMutate() { Chromosome c1, c2; char[] arr1, arr2; for (int i = 0; i < 1000; i++) { c1 = Chromosome.generateRandom(); arr1 = c1.getGene().toCharArray(); c2 = c1.mutate(); arr2 = c2.getGene().toCharArray(); assertEquals(arr1.length, arr2.length); int diff = 0; for (int j = 0; j < arr1.length; j++) { if (arr1[j] != arr2[j]) { ++diff; } } assertTrue(diff <= 1); } }