• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

EJB-QL, underscores

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I received this question in a Whizlabs test, and I'm not sure I understand this right...

Select all pattern values of a LIKE expression that would identify a word starting with a 'J' and having 'on' as the last two characters.
[A] 'J%on_'
[B] 'J*on%'
[C] 'J%on*'
[D] 'J_on%'
[E] 'J%_on_'
They give the correct answer as A,E.
Quote: "The only way to identify words having 'on' as the last two characters is by having a string that contains 'on' and an underscore, as in 'on_'.

However, I understood that '_' stands for any single character. Can it also stand for nothing?

Thanks,

Jeremy
 
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I do have the same understanding.
Quote from EJB specs page230:

The pattern-value is a string literal in
which an underscore (_) stands for any single character, a percent (%) character stands for any sequence
of characters (including the empty sequence), and all other characters stand for themselves.

 
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jeremy Wright:
I received this question in a Whizlabs test, and I'm not sure I understand this right...

Select all pattern values of a LIKE expression that would identify a word starting with a 'J' and having 'on' as the last two characters.
[A] 'J%on_'
[B] 'J*on%'
[C] 'J%on*'
[D] 'J_on%'
[E] 'J%_on_'
They give the correct answer as A,E.
Quote: "The only way to identify words having 'on' as the last two characters is by having a string that contains 'on' and an underscore, as in 'on_'.

However, I understood that '_' stands for any single character. Can it also stand for nothing?

Thanks,

Jeremy



I have the same understanding too. It seems that the answer shoud be J%on which is not in the options.
Probable they mean that It should start with J and two charecters before last character should be 'on'. That would make the answer "J%on_". Still E wouldn't be right.
reply
    Bookmark Topic Watch Topic
  • New Topic