Forum Stats

  • 3,836,707 Users
  • 2,262,168 Discussions


Confusing interview question

navale_vs Member Posts: 4
edited Oct 15, 2019 5:24AM in Java Programming

So, I went in to a recruiter for a pre-interview, which included a couple of java coding questions.  I got the first one right, but found the second one to be rather nonsense--unless I'm just that behind on java syntax.

The question:

Given an object person with a field hair-style (yes, the hyphen is part of it), how do you get the value of hair-style?

I pointed out the syntax error then said that it would have to be either if scope allows or to use an accessor method if one is provided.  The recruiter read the correct answer as person[hair-style].  They did show me the text of the question in order to confirm its contents.

I have only worked in Java up to version 8.  Is the above some change that was introduced in a later version?  I have tried searching online for more information, but am clearly not using the correct search string.


Best Answer