### Question:
SlidingCategoryDataset extends AbstractDataset implements CategoryDataset { @Override public int getColumnCount() { int last = lastCategoryIndex(); if (last == -1) { return 0; } else { return Math.max(last - this.firstCategoryIndex + 1, 0); } } SlidingCategoryDataset(CategoryDataset underlying, int firstColumn,
            int maxColumns); CategoryDataset getUnderlyingDataset(); int getFirstCategoryIndex(); void setFirstCategoryIndex(int first); int getMaximumCategoryCount(); void setMaximumCategoryCount(int max); @Override int getColumnIndex(Comparable key); @Override Comparable getColumnKey(int column); @Override List<Comparable> getColumnKeys(); @Override int getRowIndex(Comparable key); @Override Comparable getRowKey(int row); @Override List<Comparable> getRowKeys(); @Override Number getValue(Comparable rowKey, Comparable columnKey); @Override int getColumnCount(); @Override int getRowCount(); @Override Number getValue(int row, int column); @Override boolean equals(Object obj); @Override Object clone();  }### Answer:
@Test public void testGetColumnCount() { DefaultCategoryDataset underlying = new DefaultCategoryDataset(); SlidingCategoryDataset dataset = new SlidingCategoryDataset(underlying, 10, 2); assertEquals(0, dataset.getColumnCount()); underlying.addValue(1.0, "R1", "C1"); assertEquals(0, dataset.getColumnCount()); underlying.addValue(1.0, "R1", "C2"); assertEquals(0, dataset.getColumnCount()); dataset.setFirstCategoryIndex(0); assertEquals(2, dataset.getColumnCount()); underlying.addValue(1.0, "R1", "C3"); assertEquals(2, dataset.getColumnCount()); dataset.setFirstCategoryIndex(2); assertEquals(1, dataset.getColumnCount()); underlying.clear(); assertEquals(0, dataset.getColumnCount()); }