Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question about Java Operator

 
Marcos R Oliveira
Ranch Hand
Posts: 62
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Marcus Green's Mock Exam #570 the question was

And the given correct answers were 1, 2 and 3.
The explanation was that in the option 2 we have the ternary operator. Shouldn�t it be '?:' ?
Thanks for your help!
 
Corey McGlone
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, it probably should have been ?:, not just ?.
 
Darren McLeod
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Corey McGlone:
Yeah, it probably should have been ?:, not just ?.

The JLS says ? is an operator by itself and : is also an operator by itself. So just ? is valid.
Here is the reference:
JLS Operators
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic