• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Gripe about sample mock exams

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm going through some of the sample exams online and I'm seeing questions that seem rather ridiculously difficult. i.e.:
class V {
public static void main (String[] args) {
System.out.print(Float.POSITIVE_INFINITY % 2 + ",");
System.out.print(Float.NEGATIVE_INFINITY % 2 + ",");
System.out.print(2 % Float.NEGATIVE_INFINITY);
}
}
What is the result of attempting to compile and run the above program?
a. Prints: NaN,NaN,NaN
b. Prints: NaN,NaN,2.0
c. Prints: NaN,NaN,2
d. Prints: 2.0,2.0,2.0
e. Prints: 2,2,2
f. Runtime error
g. Compiler error
h. None of the above
Can I really expect questions on the exam like this?
Is this really testing my knowledge of Java or just how Java handles obscure number situations, ones I'm likely never to encounter???
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The answers are in the Java Language Specification, so they are fair game for mock exams, which do not claim to be identical to the real exam.
 
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Lots of people have said that Narcus Green's mock exams are close to the real thing, so check them out his website (http://www.jchq.net/).
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When I see a problem like this, and I don't know the answer, I am stimulated into finding out the answer and the reason for the answer. Wow! This is real cool stuff. During the process of investigation the essentials of NaN, and POSITIVE_INFINITY, et.c will be understood a little better. And so a better chance of passing the examination would be (and was) obtained. That is the intent of these mock exams.
 
Ranch Hand
Posts: 716
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let me guess..... Dan Chisolm's mock exam?
When I took the exam I saw some questions concerning MAXIMUM_VALUE of some of the wrapped classes, though nothing about POSITIVE_INFINITY.
I too found Dan's exam pitched too hard. The first two I took floored me. I came back later after more work and passed a couple of Dan's exams. At that point I knew I was very close, and in fact took and passed the actual exam two days later.
Taking a Dan Chisholm exam is a great way to start your programming day. It promotes humility and gradually you get better in Java.....
As for the question? The third expression:
System.out.print(2 % Float.NEGATIVE_INFINITY);
has to be 2.0, so it's a guess between B and D. I'd guess D because nothing about the first two expressions looks like it won't compile or to generate a NaN to me.
[ April 20, 2003: Message edited by: Alfred Neumann ]
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Alfred:
The answer is B.
Referring to the JLS, Section 15.17.3, the result of performing the remainder operation where the the dividend is an infinity, or the divisor is a zero, or both, the result is NaN. When the dividend is finite and the divisor is an infinity, the result equals the dividend. Therefore, the printed result is:
NaN,NaN,2.0
 
Warning! Way too comfortable! Do not sit! Try reading this tiny ad instead:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic