How to determine whether something is a compilation error or an exception at run time

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
flex567
Posts: 202
Joined: Mon Apr 02, 2018 8:40 am
Contact:

How to determine whether something is a compilation error or an exception at run time

Post by flex567 »

How do you differentiate if something is compilation error or a run time execption?

admin
Site Admin
Posts: 10046
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocajp.i.v7.2.1381 :

Post by admin »

flex567 wrote:
Sun Dec 16, 2018 6:33 am
How do you differentiate if something is compilation error or a run time execption?
I am not sure if there is a simple answer to this question. There are so many rules that a compiler checks while compiling code ranging from class structure, syntax, declarations, definitions, operations, and what not. If one were to pick a single most important thing then one could say that compiler checks the syntactical validity of the code but that would leave out a lot of semantic checks that the compiler performs. At run time, the JVM checks only whether the promises made by the code are being kept.

Understanding what happens at compile time and what happens at run time is a big requirement of this certification and I am afraid you will need to go through a whole book to fully understand this. I am not saying that it is difficult to understand but that there are too many rules to be listed here. If I try to list them here, this post will turn into a book :)
If you like our products and services, please help us by posting your review here.

admin
Site Admin
Posts: 10046
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: How to determine whether something is a compilation error or an exception at run time

Post by admin »

You may also see some other view points here: https://www.quora.com/Java-How-do-I-tel ... time-error
If you like our products and services, please help us by posting your review here.

flex567
Posts: 202
Joined: Mon Apr 02, 2018 8:40 am
Contact:

Re: How to determine whether something is a compilation error or an exception at run time

Post by flex567 »

Is this explained in the book?
How much is that important for the exam?

admin
Site Admin
Posts: 10046
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: How to determine whether something is a compilation error or an exception at run time

Post by admin »

I think you misunderstood what I meant by book. I mean that you need to read a whole book to understand all the rules regarding compile time vs run time. This is not something that can be explained in a single section or even a single chapter.

It is very important for the exam.
If you like our products and services, please help us by posting your review here.

flex567
Posts: 202
Joined: Mon Apr 02, 2018 8:40 am
Contact:

Re: How to determine whether something is a compilation error or an exception at run time

Post by flex567 »

How can something that is very important for the exam not be explained in a section or a chapter in Desjmukh's book? I don't think any book that is recommended for preparation for the exam covers this.
At least short explanation or summary should be included.

admin
Site Admin
Posts: 10046
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: How to determine whether something is a compilation error or an exception at run time

Post by admin »

I'm sorry but there is no magic bullet for this. It is like saying if Java programming is very important for the exam then why it isn't explained in a section!

Once you know all the rules of the language you will know what will cause error at compile time and what will cause an exception at run time. For that, you need to read the whole book. I don't think any book can explain this in a section.

May be you can ask opinion from other experts on StackOverflow or JavaRanch.
If you like our products and services, please help us by posting your review here.

admin
Site Admin
Posts: 10046
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: How to determine whether something is a compilation error or an exception at run time

Post by admin »

If compiler is able to determine that something is wrong with the code then that is a compilation error e.g. bad syntax, bad assignment, impossible casts, improper exception declarations and so on. There is a long list.

All the rest is exception at run time.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 66 guests