i didn't get what this meant by
Make the following line of code throw a java.lang.NullPointerException.
long x = y;
Answer
Long y = null;
q 2)
01 public class ConstantsCharsStrings
02 {
03 private ConstantsCharsStrings()
04 {
05
06 }
07
08 public static void main(
String[] args)
09 {
10 char c1 = 'x';
11 final char c2 = 'y';
12 int i1 = 7;
13 final int i2 = 8;
14 final int i3 = i1 >>> 3;
15 final int i4 = i2 >>> 4;
16
17 System.out.println("xxx" == (c1 + "xx"));
18 System.out.println("yxx" == (c2 + "xx"));
19 System.out.println("7xx" == (i1 + "xx"));
20 System.out.println("8xx" == (i2 + "xx"));
21 System.out.println("7xx" == (i3 + "xx"));
22 System.out.println("8xx" == (i4 + "xx"));
23 }
24 }
What is the output and why?
a) false false false false false false
b) true true true true true true
c) false true false true false true
d) false true false false true false
e) false true false true false false
f) compile-time error ________
g) runtime exception ________
h) something else ________
[ April 19, 2005: Message edited by: Parameswaran Thangavel ]