File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Associate Certification (OCAJP 7) 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 EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Associate Certification (OCAJP 7)
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
Similar Threads
switch doubt..
Refering to another class's instance of a different class, inside a class
switch statement
Do while error, I'm going crazy
How do I remove duplicates from an array?