*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes compile time  vs runtime error??? 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 "compile time  vs runtime error???" Watch "compile time  vs runtime error???" New topic
Author

compile time vs runtime error???

Shashank Sharma
Ranch Hand

Joined: Sep 27, 2006
Posts: 91
Hey can anybody please explain me how do i figure the error gonna be compile time or runtime (obj 5.2)
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6661
    
    5

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


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

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.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Shashank Sharma
Ranch Hand

Joined: Sep 27, 2006
Posts: 91
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..
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

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
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: compile time vs runtime error???
 
Similar Threads
Final Class cannot be instantiated
JSP
tricky question
Giving up too soon....
Var args ... explanation needed