Java is secure becouse it is use for malti programing support via diffrent platforms.
And is compile two times first is convert source code to byte code and second is byte code is convert in (JVM) java virchual machin .
Java's primary advantage is that you have your choice of third-party tools
(third-party IDE, third-party application server, third-party web server,
etc...) it doesn't bind you to a specific platform and it runs everywhere.
more that java support multi-programing and .NET support multi-languages