• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Compilation and "Exception thrown at runtime"

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
String test = "this is a test"
String[] tokens = test.split("\s");

what is the result ?

A.Compilation fails
B.An exception is thrown at runtime

by the way, when will occur "Compilation fails"

and when will occur "An Exception is thrown at runtime"
 
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
when you compile the code using javac (in command prompt) if .class file doesn't generate and some prints on the console that is compile time error.

and when you try to run your code using java if any exception occur at that time that is run time error
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"dodo loveme", please check your private messages. You can see them by clicking "My Profile" at the top right of the page.

Are you asking this because you don't know what "compilation fails" and "an exception is thrown at runtime" mean?

The first means that you can't compile the program, and the compiler will display an error when you try to compile it. The second means that you can successfully compile the program, but an error happens when you run it.

You can find the answer to the question quickly by writing a small program and trying to compile and/or run it.
 
Dodo Anakin
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
String test = "this is a test"
String[] tokens = test.split("\s");

what is the result ?

A.Compilation fails
B.An exception is thrown at runtime
 
Ranch Hand
Posts: 99
Mac Eclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This will give compiler error in both lines.

First line will cause compile error because the line doesn't end with ";"

Second line will cause compile error because "\s" is not a valid escape character.

For more information look at section 3.10.6 Escape Sequences for Character and String Literals.
[ August 01, 2007: Message edited by: Al Mamun ]
 
What's that smell? I think this tiny ad may have stepped in something.
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic