File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes braintester dan Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "braintester dan" Watch "braintester dan" New topic
Author

braintester dan

Dan Polak
Ranch Hand

Joined: Nov 06, 2006
Posts: 32
Check yourself , do not use JVM!!!

*List<Integer> v = new ArrayList();
*List<String> v1 = new ArrayList();
*
*out.print(v == v1); //line 3
*out.println(v.equals(v1));

a) prints falsefalse
b) compile time error
c) prints truetrue
d) if 'line 3' will be removed prints true
e) prints falsetrue
f) if 'line 3' will be removed prints false


<a href="http://www.dantheman.pl" target="_blank" rel="nofollow">http://www.dantheman.pl</a>
Xiao Song
Greenhorn

Joined: Aug 29, 2006
Posts: 17
b


scjping.......
Sanjeev Singh
Ranch Hand

Joined: Nov 01, 2006
Posts: 381
b and d
Explanations : Line 3 will results in a compilation error because it is comparing collection of two different types.
equals() in the ArrayList(implemented in AbstractList) compares all the collection objects one by one and if all matches it returns true else false.In this case there is no objects at all to compare with hence will return true.


~Sanjeev Singh<br />SCJP 1.5
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: braintester dan