Java Programming :: Operators and Assignments
-
What will be the output of the program?
class PassA { public static void main(String [] args) { passA p = new PassA(); p.start(); } void start() { long [] a1 = {3,4,5}; long [] a2 = fix(a1); System.out.print(a1[0] + a1[1] + a1[2] + " "); System.out.println(a2[0] + a2[1] + a2[2]); } long [] fix(long [] a3) { a3[1] = 7; return a3; } }
-
Which of the following are legal lines of code?
- int w = (int)888.8;
- byte x = (byte)1000L;
- long y = (byte)100;
- byte z = (byte)100L;
-
Which two statements are equivalent?
- 16*4
- 16>>2
- 16/2^2
- 16>>>2
-
import java.awt.Button; class CompareReference { public static void main(String [] args) { float f = 42.0f; float [] f1 = new float[2]; float [] f2 = new float[2]; float [] f3 = f1; long x = 42; f1[0] = 42.0f; } }
which three statements are true?
- f1 == f2
- f1 == f3
- f2 == f1[1]
- x == f1[0]
- f == f1[0]
-
Which two are equal?
- 32/4
- (8 >> 2) << 4
- 2^5
- 128 >>> 2
- 2 >> 5