aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Does not compile vs Compiles with Error? (John Hunt Mock Exam) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Does not compile vs Compiles with Error? (John Hunt Mock Exam)" Watch "Does not compile vs Compiles with Error? (John Hunt Mock Exam)" New topic
Author

Does not compile vs Compiles with Error? (John Hunt Mock Exam)

Ajay Nair
Greenhorn

Joined: Sep 03, 2000
Posts: 8
Guys, please help me out with this. The following code is from John Hunt's mock exam:Question 7
What will be the result of compiling the following code:
public class Test {
public static void main (String args []) {
int age;
age = age + 1;
System.out.println("The age is " + age);
}
}
1.Compiles and runs with no output
2.Compiles and runs printing out The age is 1
3.Compiles but generates a runtime error
4.Does not compile
5.Compiles but generates a compile time error
The answer is 4.
My question is why not 5. How do you differentiate between answers 4 and 5? What is the difference?

Rahul Agarwal
Ranch Hand

Joined: Sep 13, 2000
Posts: 52
hi
well i agree with u
According to me,there is no difference between
4)Does not compile
5)Compiles but generates a compile time error
angel custodio
Greenhorn

Joined: Aug 13, 2000
Posts: 19
Hi all,
I faced this question two days ago. IMO, answer 4 is correct, but is a kind of subtle different against answer 5:
A java source code file is "compiled" when there is no compile time error and thus, a output file .class is produced.
Therefore, if a "compile time error" is produced, no .class file is generated; so we can say "doesn't compile".

Please, correct me if i'm wrong.
Regds.
Ajay Nair
Greenhorn

Joined: Sep 03, 2000
Posts: 8
Angelo,
I am sorry I still do not get the difference.
Your statement reads this:
A java source code file is "compiled" when there is no compile time error and thus, a output file .class is produced.
Therefore, if a "compile time error" is produced, no .class file is generated; so we can say "doesn't compile".
This is precisely the doubt. If "doesn't compile" means compile time error and "compiled" means no compile time error, then what does the option 5 mean?
Hell, I am so confused!!
Guys, HELP!!!
Jane Griscti
Ranch Hand

Joined: Aug 30, 2000
Posts: 3141
Hi ... maybe 5 is referring to code that compiles ie a 'class' file is created but you get warning messages. Similar to the 'deprecated' statements.


Jane Griscti
SCJP, Co-author Mike Meyers' Java 2 Certification Passport
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Does not compile vs Compiles with Error? (John Hunt Mock Exam)