wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Dan's question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Dan Watch "Dan New topic
Author

Dan's question

mohamed hamdy
Ranch Hand

Joined: Feb 13, 2003
Posts: 72

Assume the above main method is invoked using the following
command line.
java X A B C D E F

What is the result of attempting to compile and run the program using the specified command line?
a. Prints: ABCDE
b. Prints: BCDEF
c. Prints: ABCDEF
d. Compile-time error
e. Run-time exception
f. None of the Above
the answer is e, but i think that the answer is b,e since BCDEF will be printed befor the runtime exception raised.
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
Originally posted by mohamed hamdy:
the answer is e, but i think that the answer is b,e since BCDEF will be printed befor the runtime exception raised.

I agree.


SCJP Tipline, etc.
Dan Chisholm
Ranch Hand

Joined: Jul 02, 2002
Posts: 1865
I also agree. I'll update the answer.


Dan Chisholm<br />SCJP 1.4<br /> <br /><a href="http://www.danchisholm.net/" target="_blank" rel="nofollow">Try my mock exam.</a>
Ty Truong
Greenhorn

Joined: May 06, 2003
Posts: 1
When I ran it, it throws runtime exception error without printing anything which is match the answer e only not b.
Edwin Keeton
Greenhorn

Joined: Jul 22, 2002
Posts: 18
I get:
B
C
D
E
F
java.lang.ArrayIndexOutOfBoundsException: 6
at X.main(X.java:14)
Exception in thread "main"
Robbie kyodo
Ranch Hand

Joined: May 05, 2003
Posts: 97
Yeah, should be B
C
D
E
F
ArrayOutofbound.


SCJP 2 1.4
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Dan's question
 
Similar Threads
Exception logic.
could some one explain how the control flows on the following code..
Confused about Dan's Exam #1 Question #27
Dan's exam: Question 4, Langauage Fundamentals, Main Method
q on primitives