Hi ,
following questions are from jxam mock exam.
Q#1
Given the following definition:
String s = null;
Which code fragment will cause an exception of type NullPointerException to be thrown.
1. if ((s != null) & (s.length()>0))
2. if ((s != null) && (s.length()>0))
3. if ((s != null) | (s.length()>0))
4. if ((s != null) | | (s.length()>0))
5. none
given answer is 1,2,3,4.
i am sure '2' is not a valid answer. please do varify it.
Q#2
Which of the following statements are true regarding inner classes.
1. Variables defined inside inner classes cannot be static.
2. Variables defined inside inner classes cannot be static unless the inner class itself is static.
3. Non-static inner classes (which are not defined in a method) have access to all class and instance variables, regardless of the access qualifier of those variables.
4. An inner class can actually be a subclass of the outer class
5. Inner classes can be declared as private. Top level, outer classes cannot.
given answer is 2,3,4,5. but what is wrong with '1'.
please explain it to me.
vivek