• 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

a mock question about EJB query

 
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a question about EJB query,I think the answer would be C,but given answer is E,anyone can clear this for me.thanks!

A developer wants to create a Java Persistence query that returns valid U.S. phone numbers
(formatted as "123-456-7890" or "800-RUN-EJB3") from a collection of differently formatted
international phone numbers. The developer needs only those numbers that begin with 303.
Which WHERE clause is correct?
A. WHERE addr.phone LIKE '303_'
B. WHERE addr.phone LIKE '303%'
C. WHERE addr.phone LIKE '303-_-_'
D. WHERE addr.phone LIKE '303-%-%'
E. WHERE addr.phone LIKE '303--
F. WHERE addr.phone LIKE '303-%%%-%%%%'
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think the good answer is
'303-___-____'

_ means one character
% means zero, one or more characters
so
A. WHERE addr.phone LIKE '303_' - bad answer, matching numbers 3031, 3030, ...
B. WHERE addr.phone LIKE '303%' - bad answer, matching numbers 3031,303-156-1, 303anything_more
C. WHERE addr.phone LIKE '303-_-_' - bad answer, matching numbers 303-1-1, 303-5-6 but not 303-456-7890
D. WHERE addr.phone LIKE '303-%-%' - the best answer from those listed but it is also wrong because it doesn't control size of number, it will match also 303-123456789-45648465564
E. WHERE addr.phone LIKE '303-- - bad answer - this is meaningless
F. WHERE addr.phone LIKE '303-%%%-%%%%' - bad answer, it doesn't control size of number also
 
vitesse wei
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks!Adam.
 
This guy is skipping without a rope. At least, that's what this tiny ad said:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic