I recently faced this problem, when I was asked to write a simple String program in a text editor like notepad. I knew the logic but the ease of using an IDE like eclipse, where you don't have to remember the imports/packages, I failed to answer the question.
The solution is practice, practice and practice. Go for good tutorial videos, blogs and try to write it down somewhere. Write a story on hashnode, which will help you out with your last minute preparations. Several sites are available for technical quizzes with different difficulty levels, you can revise with that.