• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Jxam

 
Vivek Shrivastava
Ranch Hand
Posts: 277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
These questions are from Jxam mock exam and i think given answers are not correct.
Q#1
Choose the class that can hold multiple equal objects in an ordered way.
A. Map
B. Collection
C. List
D. Set
E. Vector
Given answer is 'C' but List is not a class, it is a interface. Vector is a class that implements List interface. i think answer should be 'E'.

Q#2
Given the following definition:
String s = null;

Which code fragment will cause an exception of type NullPointerException to be thrown.
A. if ((s != null) & (s.length()>0))
B. if ((s != null) && (s.length()>0))
C. if ((s != null) | (s.length()>0))
D. if ((s != null) | | (s.length()>0))
Given answer are 'A','B','C','D'. but i think 'B' is not correct ( LHS will give u false then RHS will not be executed).
Q#3
Which of the following are defined in the Object class?
A. toString()
B. equals(Object o)
C. public static void main(String arg[])
D. System.out.println()
E. wait()
given answer are 'B' and 'E'. what is wrong with 'A'?
please do verify.
vivek
[This message has been edited by Vivek Shrivastava (edited August 05, 2000).]
[This message has been edited by Vivek Shrivastava (edited August 06, 2000).]
 
Gopinath Rajgopal
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vivek,
I agree with you.....
1. List is an interface and not a class.
2. Yes, the boolean expression short circuits if s is null
3. toString() is a method in Object class.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Q#1 :The elements in vector are not ordered. If they just say List class, the only List class we have is java.awt.List.Probably, the question should be rephrased.
Q#2 : you are right.
Q#3 : you are right.

[This message has been edited by vasansrini (edited August 05, 2000).]
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vivek,
Why do you think that the answer to question 1 should be 'D'.
Even Set is an interface.
In fact except Vector, all the other possible alternatives are interfaces.
Rgds,
Shashank
 
KN
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shashank,
You are right. Set is also an interface but it can't have equal objects ( which is mentioned in the question 1). It stores unique objects.
Thanks,
Kiran.
 
Vivek Shrivastava
Ranch Hand
Posts: 277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That was typo. i have edited my first posting.
vivek
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic