Hi Ailsa,
Wow, Ancestry really messed up that 1881 transcription… Jane and Alex are put with another family and two other Beveridges are attached to John's family instead. The household schedule numbers at least allow one to reconstruct the families…
So this looks like them in 1871:
1871
Back St N Side, Burntisland, Fife
John Beveridge, 33, Head, born Crossgates, Fifeshire, Steamboat Stoker
Elizabeth Beveridge, 28, Wife, born Hawick, Roxburgh
Ellen Beveridge, 3, Daughter, born Burntisland, Fife
Jane Beveridge, 1, Daughter, born Burntisland, Fife
Could this be him in 1841? Notice there is also a James in this family, the same age as your James

Sorry, doesn't look like this is ending up to be your John, but there are so many Johns in the Dunfermline area that it's really anybody's guess which is the right one.
1841
Crossgates Danf Str, Dunfermline, Fife
John Beveridge, 50, born Fife, Coal M
Grace Beveridge, 40, born Scotland
Mary Beveridge, 14, born Fife
James Beveridge, 11, born Fife
John Beveridge, 2, born Fife
Just for fun, there's this guy. Don't ask me what he is supposed to be teaching:
1861
16 Wood St, Sorn Ayrshire
John Beveridge, 24, Head, born Dunfermline, Fifeshire, Teacher of Edwatron Onbrey Employ

Sarah