Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Another Dan's erroneous definition?

 
Vad Fogel
Ranch Hand
Posts: 504
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is from comprehensive exam 10:

Question 17
Which of the class instance creation expressions would produce a run-time error?
a. Long.parseLong("1")
b. Long.parseLong("1L")
c. Long.parseLong("010")
d. Long.parseLong("0x10")
e. Long.parseLong("1.0")

There are no class instance creation expressions in this question. If it were valueOf(String str), then probably yes.
 
Jose Botella
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree that no instance creation can be inferred from reading the API for Long.parseLong
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I even looked at the code and there is no instance creation except for instantiation of a NumberFormatException if the String contains non-numeric data.
 
Dan Chisholm
Ranch Hand
Posts: 1865
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Vad Fogel:
There are no class instance creation expressions in this question. If it were valueOf(String str), then probably yes.

You are correct. They are obviously method invocation expressions. If you see any more of those types of errors, the please let me know.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic