Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jtips mock 1 Q33

 
Neha Sawant
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Q33 from jtips mock 1
I thought it should give compiler error,statement not reached but ans given is 18.
Please help
Given:

What is the Output?
1.Prints 10
2.Prints 28
3.Compile-time error occurs.
4.Prints 18.
5.Prints 27
regards
neha

(Marilyn added code tags)
[This message has been edited by Marilyn deQueiroz (edited November 27, 2001).]
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Answer is wrong. It gives a compile error. Try to compile the code and you'll see it. The only construct with which you can use false is with "if" so that you may insert debug conditional compilation.
HIH
------------------
Valentin Crettaz
Sun Certified Programmer for Java 2 Platform
 
Magnus Lidman
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you use JBuilder, it'll compile (but the statement will hopefully be optimized away), but if you use SUN's own compiler (javac) you'll get the error.
Guess the author of the mock-exam uses JBuilder or something similar.
Originally posted by Valentin Crettaz:
[b]Answer is wrong. It gives a compile error. Try to compile the code and you'll see it. The only construct with which you can use false is with "if" so that you may insert debug conditional compilation.
HIH
[/B]

 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Magnus, those kind of things are always good to know...
------------------
Valentin Crettaz
Sun Certified Programmer for Java 2 Platform
 
Neha Sawant
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanx Mangus and Valentin
Regards
Neha
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic