gcc --version and package version is not the same

When i enter following command in the terminal:

gcc --version

It's output something like this:

gcc (Ubuntu 6.5.0-2ubuntu1~18.04) 6.5.0 20181026
...

But when i enter below command to see version of the installed gcc package:

apt-cache show gcc | grep Version

I see this:

Version: 4:7.4.0-1ubuntu2.2
Version: 4:7.3.0-3ubuntu2.1
Version: 4:7.3.0-3ubuntu2

Is it normal?

Which version used by software that needs gcc?


gcc is installed on your Ubuntu (18.04, 18.10 or 19.04) as well gcc-6 and possibly some other gcc version(s). Although gcc is installed, gcc-6 is currently the default version of gcc. To show all the versions of gcc installed on your OS, run the following command:

apt policy gcc gcc-5 gcc-6 gcc-7 gcc-8 gcc-9     

As you can see from the results of the above command, there are several different alternative versions of gcc in the default Ubuntu repositories, and multiple versions of gcc can be installed alongside each other. You can select which version of gcc to use if multiple versions are installed by following the instructions in How to use multiple instances of gcc?.