• 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

two possible answers Q18 ch 4 page 282 from KB

 
Ranch Hand
Posts: 787
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If the code presents an statement that will give compilation error and another statement that might throw runtime error, but question says pick one answer, than what should be answered:
Here is the code:

The answer is compilation error at line 14. But I guess there is runtime error at line 13 as well.
[ July 15, 2003: Message edited by: Barkat Mardhani ]
 
Ranch Hand
Posts: 1561
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, why do you think there's a runtime error?
foo() is void, so there's a compiler error, since the second expression of the assertion must return a value.
let me know...
[ July 15, 2003: Message edited by: Andres Gonzalez ]
[ July 15, 2003: Message edited by: Andres Gonzalez ]
 
Ranch Hand
Posts: 1090
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Barkat
First if there is only one possible answer select the one that says does not compile. If they want two answers select the other one. But it sounds absurd to ask for a runtime error along with a compilation error. How can you ever have a runtime error when you can not even compile the program.
Secondly which error are you talking about. I only encountered an AssertionError(after removing the compilation error).
For this question I would say that the answer should be compilation error alongwith any other suitable answer(if any). Runtime error at line 13 is wrong.
[ July 15, 2003: Message edited by: Anupam Sinha ]
 
Barkat Mardhani
Ranch Hand
Posts: 787
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The AssertaionError is the runtime error I am talking about.
 
Anupam Sinha
Ranch Hand
Posts: 1090
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Barkat

The answer is compilation error at line 14. But I guess there is runtime error at line 13 as well.


It is not possible for the code to even compile how can it have an AssertionError.
[ July 15, 2003: Message edited by: Anupam Sinha ]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic