• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

assertions

 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
from Sierra and Bates.


Which of the following invocations will run without exception? (Choose all that apply.)
A. java Motel13
B. java -ea Motel13
C. java -da:Hotel Motel13
D. java -da:Motel13 Motel13
E. java -ea -da:Hotel Motel13
F. java -ea -da:Motel13 Motel13

Answer (for Objective 2.3):
A, C, D, and F are correct. When assertions are enabled, the Motel13 class will throw
an AssertionError, the Hotel class will not. Invocations A, C, and D do not enable
assertions for Motel13. F is correct because although assertions were enabled, the "–da"
switch selectively disabled assertions for the Motel13 class.
B and E are incorrect because assertions are enabled for Motel13.

Why is E not a correct answer? I read "java -ea -da:Hotel Motel13" as enable assertions for all classes and disable assertions for classes Hotel and Motel13.

Thanks.

Matt

 
Ranch Hand
Posts: 924
1
Netbeans IDE Fedora Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

matt love wrote:from Sierra and Bates.


Which of the following invocations will run without exception? (Choose all that apply.)
A. java Motel13
B. java -ea Motel13
C. java -da:Hotel Motel13
D. java -da:Motel13 Motel13
E. java -ea -da:Hotel Motel13
F. java -ea -da:Motel13 Motel13

Answer (for Objective 2.3):
A, C, D, and F are correct. When assertions are enabled, the Motel13 class will throw
an AssertionError, the Hotel class will not. Invocations A, C, and D do not enable
assertions for Motel13. F is correct because although assertions were enabled, the "–da"
switch selectively disabled assertions for the Motel13 class.
B and E are incorrect because assertions are enabled for Motel13.

Why is E not a correct answer? I read "java -ea -da:Hotel Motel13" as enable assertions for all classes and disable assertions for classes Hotel and Motel13.

Thanks.

Matt



java -ea -da:Hotel Motel13 is read as enable assertions for all the classes and disable assertions for the Hotel class and run the class file Motel13. the argument to the option -da are just Hotel. Motel13 is argument to java, i.e. it is the class file we are trying to run.
 
matt love
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Great answer Gurpeet.

Thanks.

Matt

 
Listen. That's my theme music. That's how I know I'm a super hero. That, and this tiny ad told me:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic