UNIT – 1 JAVA QUESTION BANK
2
Define Literals and its types?
▹ Literals are data used for representing fixed values.
They can be used directly in the code.
▸ Eg: int a = 1; float b = 2.5; char c = 'F'
▸ Here 1, 2.5, and 'F' are literals.
3
How Java achieves platform independence? Justify with
your answer.
Java is platform-independent because it uses a virtual
machine.
All APIs are compiled into bytecodes.
Bytecodes are effectively platform-independent.
4
Write a java program for sorting numbers using
built in functions.
import java.util.Arrays;
public class Main {
public static void main(String[] args) {
int[] intArray = {12, 87, 23, 7};
System.out.printf("Original Array : %s",
5
Arrays.toString(intArray));
Arrays.sort(intArray);
System.out.printf("nnSortedArray : %s",
Arrays.toString(intArray));
}
}

123.ppt