Dell OptiPlex 7040 MT vs. HP ProDesk 400 G2 Microtower
Comparison and Differences
Differences between Dell OptiPlex 7040 MT and HP ProDesk 400 G2 Microtower
If you are looking for a more modern desktop, then you should go with the Dell OptiPlex 7040 MT which was released in 2015. The HP ProDesk 400 G2 Microtower is older and entered production in 2014.
Both models have the same form factor, meaning reoughtly they have the same phiysical size and form.
Processor
Usually the newer the generation of the CPU, the better the performance and efficiency is. If your budget allows it, you should go with the Dell OptiPlex 7040 MT as it is running a newer generation CPU. This is not to say that HP ProDesk 400 G2 Microtower is bad - it can still run some powerful CPUs, albeit being an older generation.
Memory
The Dell OptiPlex 7040 MT has 4 RAM slots while the HP ProDesk 400 G2 Microtower has only 2 slot(s). This is not something to worry about. Just make sure you take it into consideration when planning how much RAM you are going to use.
The Dell OptiPlex 7040 MT is using the faster 2133 MT/s RAM. The HP ProDesk 400 G2 Microtower is slower by supporting RAM speeds of up to 1600 MT/s. Additionally, if you will be needing a lot of RAM, better go for the Dell OptiPlex 7040 MT as it has the ability to run 64 GB of RAM. The HP ProDesk 400 G2 Microtower can do a bit less at max 16 GB. Most of the times, this should be sufficient for the majority of users.
Ports
In total the Dell OptiPlex 7040 MT has 10 USB ports. The HP ProDesk 400 G2 Microtower is inferior in this regard and packs 6 USB ports. In any case, if you miss USB ports, you can always purchase a USB hub. None of the desktop models has a USB 3.1 port (10Gb/s), so if you need a fast connection to your peripherals, like external Solid State Drive, you will need to look elsewhere.
Unfortunately, only the Dell OptiPlex 7040 MT has a DisplayPort. The HP ProDesk 400 G2 Microtower does not have one? Don't worry though, nowadays video adapters are cheap and you can get almost any combination of conversion types.
The Dell OptiPlex 7040 MT comes with an HDMI port, while the HP ProDesk 400 G2 Microtower does not support the interface. Of course missing HDMI port is something that can be easily fixed with a good adapter (e.g. DisplayPort to HDMI).
SATA ports are placed on the system board and it is where you connect your HDD, SSD and Optical Disk Drives. More SATA slots will allow you to have more drives running at the same time. In this regard the Dell OptiPlex 7040 MT is better equipped as it comes with 4 SATA slot(s), while the HP ProDesk 400 G2 Microtower has 3 slot(s).
If you want the fastest transfer speeds for your SSD, an M.2 interface is crucial. Thus, if the M.2 SSD slot is a mandatory requirement for you, go with the Dell OptiPlex 7040 MT. Sadly, the HP ProDesk 400 G2 Microtower has no such slot, and you will be forced to use the SATA interface instead.
Make sure that the available M.2 slot supports the PCIe (also called NVMe) interface. This is important as there are M.2 slots which support only the inferior SATA III interface. For comparison, the SATA III interface has max speeds of 6Gb/s, while the PCIe 3.0 x4 will support speeds up to 32Gb/s!
Power Supply
Having a Power Supply Unit with high power rating is important, if you are going to use components which require extra power. The Dell OptiPlex 7040 MT comes with a decent 240 Watt PSU, but the HP ProDesk 400 G2 Microtower has a more powerful one rated at 300 Watts. Choosing either one depends on your specific requirements and use case. Also don't forget that some models might have more than one PSU option - try to always get the most powerful one, especially if you plan to upgrade to a powerful GPU.