### Question:
INodeFile extends INode implements BlockCollection { void appendBlocks(INodeFile [] inodes, int totalAddedBlocks) { int size = this.blocks.length; BlockInfo[] newlist = new BlockInfo[size + totalAddedBlocks]; System.arraycopy(this.blocks, 0, newlist, 0, size); for(INodeFile in: inodes) { System.arraycopy(in.blocks, 0, newlist, size, in.blocks.length); size += in.blocks.length; } for(BlockInfo bi: newlist) { bi.setBlockCollection(this); } this.blocks = newlist; } INodeFile(PermissionStatus permissions, BlockInfo[] blklist,
                      short replication, long modificationTime,
                      long atime, long preferredBlockSize); static INodeFile valueOf(INode inode, String path); @Override short getBlockReplication(); @Override long getPreferredBlockSize(); @Override BlockInfo[] getBlocks(); void setBlock(int idx, BlockInfo blk); @Override String getName(); @Override BlockInfo getLastBlock(); @Override int numBlocks();  }### Answer:
@Test public void testAppendBlocks() { INodeFile origFile = createINodeFiles(1, "origfile")[0]; assertEquals("Number of blocks didn't match", origFile.numBlocks(), 1L); INodeFile[] appendFiles = createINodeFiles(4, "appendfile"); origFile.appendBlocks(appendFiles, getTotalBlocks(appendFiles)); assertEquals("Number of blocks didn't match", origFile.numBlocks(), 5L); }