Java Interview Questions

Q1: Is Java Platform dependent ?

A: No, Java is a platform independent language. A platform independent language doesn’t depend on the operating system or hardware. Unlike programming languages like C++ or C which are platform dependent and won’t run on every platform.

Q2: What makes Java a platform independent language?

A: Java uses the javac compiler to compile java code to byte code. Byte code is what makes java platform independent. It can be run by any java virtual machine(JVM). The JVM is Platform dependent.

Q3: Can you change the contents of a final array “names”?

final String names[]= new String[10];
names[0]= "Kevin";

A: Yes, you can actually change the contents of “names” because in this use case of final, it will only lock the memory address of “names”, preventing any attempts of changing its memory location.

final String names= new String[3];
String otherNames= new String[3];

//Error, address of names can't be changed!
names= otherNames;


Leave a comment

Design a site like this with WordPress.com
Get started