Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Dan's question

 
mohamed hamdy
Ranch Hand
Posts: 72
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 3271
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Dan Chisholm
Ranch Hand
Posts: 1865
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I also agree. I'll update the answer.
 
Ty Truong
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I ran it, it throws runtime exception error without printing anything which is match the answer e only not b.
 
Edwin Keeton
Greenhorn
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 97
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, should be B
C
D
E
F
ArrayOutofbound.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic