Java Quiz 4

What will be output of this simple java program ?

 
OCJP Quiz

 

Click button below to answer the quiz :

 

 

 

Reference : GoogleTEDTalks

© 2015 – 2016, https:. All rights reserved. On republishing this post, you must provide link to original post

7 comments

  1. This code will not compile. It gives the error “The type HashSet is not generic; it cannot be parameterized with arguments “.

  2. It is a good question.this question replace set.remove(i-1) to set.remove((short)(i-1)) when answer is 1

  3. Even i by itself is type “short”, the calculation result of “i-i” is type int, which need explicitly cast to “short”, the set cannot find the Integer “i-1” in Short Set.

  4. […] Article 4: Java Quiz 4 (Nice puzzle on datatypes) […]

  5. what is the GoogleTEDTalks where this question appears?

    1. This question was discussed in a TED talks video and is available in YouTube. The video was shared with id GoogleTEDTalks. You could search for GoogleTEDTalks in YouTube and should en able to get it.

Leave a Reply.. code can be added in <code> </code> tags

%d bloggers like this: