• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Dan's question

 
Ranch Hand
Posts: 72
  • 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.
 
Ranch Hand
Posts: 3271
  • 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.
 
Ranch Hand
Posts: 1865
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I also agree. I'll update the answer.
 
Greenhorn
Posts: 1
  • 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.
 
Greenhorn
Posts: 18
  • 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"
 
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, should be B
C
D
E
F
ArrayOutofbound.
 
Why is the word "abbreviation" so long? And this ad is so short?
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic