Why same solution takes different time in C++ and java

my code is accepting on geek for geeks online platform where as a same solution in java accepted as it was taking less time. how can we reduce the time taken in java. Is it due to Scanner class or any other reason.