3D hierarchical graphitic carbon nanowalls encapsulating cobalt nanoparticles HPC-Co were prepared in high yield from solid-state pyrolysis of cobalt 2,2′-bipyridine chloride complex. Annealing of HPC-Co in air gave HPC-CoO, which consists of a mixture of crystallite Co3O4 nanospheres and nanorods bursting out of mesoporous carbon. Both nanocomposites were fully characterized using SEM, TEM, BET, and powder X-ray diffraction. The elemental composition of both nanocomposites examined using SEM elemental mapping and TEM elemental mapping supports the successful doping of nitrogen. The powder X-ray diffraction studies supported the formation of hexagonal cobalt in HPC-Co, and cubic crystalline Co3O4 with cubic cobalt in HPC-CoO. HPC-Co and HPC-CoO can be used as a modified carbon electrode in cyclic voltammetry experiments for the detection of fructose with limit of detection LOD 0.5 mM. However, the single-frequency impedimetric method has a wider dynamic range of 8.0–53.0 mM and a sensitivity of 24.87 Ω mM−1 for the electrode modified with HPC-Co and 8.0–87.6 mM and a sensitivity of 1.988 Ω mM−1 for the electrode modified with HPC-CoO. The LOD values are 3 and 4 mM, respectively. The effect of interference increases in the following order: ascorbic acid, ethanol, urea, and glucose. A simple method was used with negligible interference from glucose to measure the percentage of fructose in a corn syrup sample with an HPC-CoO electrode. A specific capacitance of 47.0 F/g with 76.6% retentivity was achieved for HPC-Co and 28.2 F/g with 87.9% for HPC-CoO for 3000 charge–discharge cycles. Thus, (1) has better sensitivity and specific capacitance than (2), because (1) has a higher surface area and less agglomerated cobalt nanoparticles than (2).