Java Interview Questions
1 .
Can a .java file contain more than one java classes?
Yes, a .java file contains more than one java classes, provided at the most one of them is a public class.
2 .
What is a unicode system?
unicode system is an encoding standard that provides a unique number for every character, no matter what the platform, program, or language is. Unicode uses 2  bytes to represent a single character.
3 .
What is the difference between float and double?
float can represent up to 7 digits accurately after decimal point, whereas double can represent up to 15 digits accurately after decimal point.
4 .
What happens if you don’t initialize an instance variable of any of the primitive types in Java?
Java by default initializes it to the default value for that primitive type. Thus an int will be initialized to 0, a boolean will be initialized to false.
5 .
What is the default value of the local variables?
The local variables are not initialized to any default value, neither primitives nor object references. If you try to use these variables without initializing them  explicitly, the java compiler will not compile the code. It will complain about the local variable not being initialized.
6 .
What is the difference between declaring a variable and defining a variable?
In declaration we just mention the type of the variable and its name. We do not initialize it. But defining means declaration + initialization. e.g. String s; is just  a declaration while String s = new String ("abcd"); Or String s = "abcd"; are both definitions.
7 .
What is the % operator?
It is referred to as the modulo or remainder operator. It returns the remainder of dividing the first operand by the second operand.
8 .
Which Java operator is right associative?
The = operator is right associative.
9 .
Can a double value be cast to a byte?
Yes, a double value can be cast to a byte.
10 .
What are order of precedence and associativity, and how are they used?
Order of precedence determines the order in which operators are evaluated in expressions. Associativity determines whether an expression is evaluated left-to-right or right-to-left.