You can write the book in any way you choose, as long as it works for you. However, you should always keep in mind that books are good because of their characters, not just because of the "exciting" scene. So, while you can write down elements of your book in any order you want, you should have a very good idea of who your characters are, regardless.
It's worth mentioning that you may create more work for yourself later on down the line by writing things out of sequence. Very often characters take on a life on their own as you write, so you could find yourself jumping back to an earlier scene, writing something that "works", but which could invalidate or ruin everything else you wrote.
To pick a random example, maybe the hero is fighting the Ninjas on sharks, and doesn't hesitate to shoot them all to pieces. However, when you jump to an earlier bit, you decide it's a great idea for the character to fall in love with one of the killer Ninjas, or perhaps make one of the sharks his pet that he had raised for many years before it got stolen and trained into a hero-killing machine.
Suddenly, your action scene might not make sense, because the character would be completely conflicted in wantonly killing his lover Ninja and/or his favourite pet shark.
Or perhaps you suddenly realise that there's no way the evil mastermind will have Ninjas on sharks, he'd have Ninjas on leopards.
Either way, you likely have to start planning some major re-writes of your later scenes.
I personally wouldn't consider writing a novel or short story in the way you describe. It's often the case that the best ideas for what happens next unfold as you write, and if you've already "written ahead", you may well be boxing in your creativity. You could force yourself down a particular train of thought, and ignore other, better ideas and solutions that come up in order to stick to what you've already done.