Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

a mock question about EJB query

 
vitesse wei
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • 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-%%%-%%%%'
 
Adam Tkaczyk
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
thanks!Adam.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic