Back

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 SampleOperations { public static void main(String args[]) { int a = 3; int b = 6; int c = a | b; int d = a & b; System.out.println(c + " " + d); } }

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); } }

Decide the output of the following Java code?

class Test { public static void main(String[] args) { int g = -3; System.out.print(++g * 8); } }

Which operator is used to invert all the digits in a binary representation of a number?

Decide the output of the following Java code?

class Update { public static void main(String args[]) { double var1 = 1 + 5; double var2 = var1 / 4; int var3 = 1 + 5; int var4 = var3 / 4; System.out.print(var2 + " " + var4); } }

Which of these is not a bitwise operator?

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); } }

Decide the output of the following Java code?

class Operations { public static void main(String args[]) { int var1 = -42; int var2 = ~var1; System.out.print(var1 + " " + var2); } }

Enroll For Course !