This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
The moose likes Associate Certification (OCAJP 7/8) and the fly likes Switch Statement using String on OCA 7 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Certification » Associate Certification (OCAJP 7/8)
Bookmark "Switch Statement using String on OCA 7" Watch "Switch Statement using String on OCA 7" New topic

Switch Statement using String on OCA 7

Glenn Gould

Joined: Jul 09, 2013
Posts: 5
The following program compiles from the command prompt and uses the String object in the switch statement.

Question : Has anyone that has taken the exam seen the String object used with the switch statement?
Brandon Mikel

Joined: Jun 18, 2013
Posts: 3
Most definitely. I only recall one example (took it yesterday). It was something like:

And then it asked what the output would be. Apologies if I've got any syntax wrong, I just threw that together.

The output in this case would be:
"Not a fish at all"
Due to the case of the string blah, which is all lower-case, while the "Tuna" case has a capital 'T'.
I agree. Here's the link:
subject: Switch Statement using String on OCA 7