aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes K&B Master Exam Regex Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "K&B Master Exam Regex Question" Watch "K&B Master Exam Regex Question" New topic
Author

K&B Master Exam Regex Question

Edisandro Bessa
Ranch Hand

Joined: Jan 19, 2006
Posts: 584
Hi guys,

Maybe I misunderstood the below question. Could you please give me your opinions.

What are true about Java Regex ? (Choose all that apply)

a) The \w metacharacter searches for whitespaces.
b) The \b metacharacter searches for numeric digits.
c) The . metacharacter searches for alphabetic characters.
d) The String [af] searches for a,b,c,d,e or f characters.

In my first attempt I chose B and C but according to MasterExam explanation the correct answer is only B.

The explanation for C as incorrect is because . metacharacter searches for any character.

I personally don't agree with this explanation. I think option C would be incorrect if it was stated in this way :

c) The . metacharacter searches only for alphabetic characters.


I'm really interested about your comments.

Thanks.


"If someone asks you to do something you don't know how to, don't tell I don't know, tell I can learn instead." - Myself
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18896
    
  40


a) The \w metacharacter searches for whitespaces.
b) The \b metacharacter searches for numeric digits.
c) The . metacharacter searches for alphabetic characters.
d) The String [af] searches for a,b,c,d,e or f characters.


I don't think any of these choices are correct. Choice B is wrong because "\b" is for matching of a word boundary.


I personally don't agree with this explanation. I think option C would be incorrect if it was stated in this way :

c) The . metacharacter searches only for alphabetic characters.


Hard call... How about this as an example? If you tell one of your programmers to look for numbers, and when he delivers the program, it doesn't work because you didn't tell him to only look for numbers...

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Edisandro Bessa
Ranch Hand

Joined: Jan 19, 2006
Posts: 584
Hi Henry,

Thank you so much for your prompt reply.

First of all, I've just realized that I mistyped the option B. The correct sentence is :

b) The \d metacharacter searches for numeric digits.

Sorry for that, now I think B is correct and makes sense, doesn't it ?

Henry, as I said before, maybe I misunderstood the question and what you said about tell one of my programmers to look for numbers is indeed another perspective to consider.

I'm really worried about how interpret such kind of questions in the exam. I really don't want to miss such simple question just because I mislead it.

For me, the option C has double sense. Do you have some tip or some kind of rule which could help me to decide better in the exam ?

Thanks in advance Henry.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18896
    
  40

Henry, as I said before, maybe I misunderstood the question and what you said about tell one of my programmers to look for numbers is indeed another perspective to consider.

I'm really worried about how interpret such kind of questions in the exam. I really don't want to miss such simple question just because I mislead it.

For me, the option C has double sense. Do you have some tip or some kind of rule which could help me to decide better in the exam ?

Thanks in advance Henry.


Well, I would just not worry about it... I don't think there will enough of these really subtle distinctions in questions to greatly affect your overall score -- unless you are either going for a perfect score, or believe you are borderline between passing and failing...

Another option. Just remember that you are taking a Java certification test -- and not the LSAT.

Henry
Edisandro Bessa
Ranch Hand

Joined: Jan 19, 2006
Posts: 584
Thanks Henry
Bert Bates
author
Sheriff

Joined: Oct 14, 2002
Posts: 8829
    
    5
Hi Guys,

I guess we'll add the word "only" to options A, B, and C. (e.g. "searches only for...")

I don't think you'll run into an issue like this on the real exam, first of all, on the real exam you'll be told how many answers are correct which, I think, would have made this question easier.

hth,

Bert


Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: K&B Master Exam Regex Question