• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

compile time vs runtime error???

 
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey can anybody please explain me how do i figure the error gonna be compile time or runtime (obj 5.2)
 
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Usually the exam tests to see if you recognize checked exceptions that lead to compile time errors and runtime exceptions that lead to runtime errors.

Any exception that extends from the Exception class is a checked exception.
Any exception that extends from the RuntimeException is a runtime exception.

With more practice you should be able to differentiate between the two
 
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
What John writes about is the difference between checked and unchecked exceptions; that is not the same as runtime vs. compile time errors.

Compile time errors are errors in your source code, that the compiler will give an error message about. Syntax errors and other errors in your source code are compile time errors.

Runtime errors are errors that happen later, when you run your program.
 
Shashank Sharma
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
isnt there any fix rule that what makes error to be thrown at run time or at compile time..like NoSuchMethod is thown at compile time..
 
author and cow tipper
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I may be comming in a little late on the discussion, but I hope this contrubution adds to the discussion.

I have a little set of mock exam questions on this subject that tries to drive home when something won't compile, when an Exception will get thrown, and when a RuntimeException might get thrown. I put the mock exam questions in a new JavaRanch thread so as not to hijack this one:

Mock SCJP 6.0 Exam Questions on Execptions vs. Compile Errors vs. Just Good Code!

You can see the original posting at my blog if you're interested.

-Cameron McKenzie
[ July 21, 2008: Message edited by: Cameron Wallace McKenzie ]
 
Jesper de Jong
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

Originally posted by Shashank Sharma:
like NoSuchMethod is thown at compile time..


No, it isn't. Exceptions are never thrown at compile time. And NoSuchMethodError is an exception that could happen at runtime.
 
reply
    Bookmark Topic Watch Topic
  • New Topic