Welcome to your Java Practice Test - 1
Which of the following are legal lines of Java code?
1. int w = (int)888.8; 2. byte x = (byte)100L; 3. long y = (byte)100; 4. byte z = (byte)100L;
Decide the output of the following Java code?
class NareshIt { public static void main(String args[]) { double a, b,c; a = 3.0/0; b = 0/4.0; c=0/0.0; System.out.println(a); System.out.println(b); System.out.println(c); } }
With x = 0, which of the following are legal lines of Java code for changing the value of x to 1?
1. x++; 2. x = x + 1; 3. x += 1; 4. x =+ 1;
What will be the output of the following Java code?
class Average { public static void main(String args[]) { double num[] = {5.5, 10.1, 11, 12.8, 56.9, 2.5}; double result= 0; for (int i = 0; i < num.length; ++i) result = result + num[i]; System.out.print(result/6); } }