exam questions

Exam 1z0-804 All Questions

View all questions & answers for the 1z0-804 exam

Exam 1z0-804 topic 1 question 45 discussion

Actual exam question from Oracle's 1z0-804
Question #: 45
Topic #: 1
[All 1z0-804 Questions]

Given:

And the commands:
javac Test.java
java ea Test
What is the result?

  • A. Compilation fails
  • B. Standard Edition Enterprise Edition Micro Edition
  • C. Standard Edition class java.lang.AssertionError Micro Edition
  • D. Standard Edition is printed and an Assertion Error is thrown
Show Suggested Answer Hide Answer
Suggested Answer: D 🗳️
javac Test.java
will compile the program.
As for command line:
java ea Test
First the code will produce the output:

Standard Edition -
See Note below.
The ea option will enable assertions. This will make the following line in the switch statement to be run: default: assert false;
This will throw an assertion error. This error will be caught. An the class of the assertion error (class java.lang.AssertionError) will be printed by the following line:
System.out.println(e.getClass());
Note:The java tool launches a Java application. It does this by starting a Java runtime environment, loading a specified class, and invoking that class's main method. The method declaration must look like the following: public static void main(String args[])
Paramater ea:
-enableassertions[:<package name>"..." | :<class name> ] -ea[:<package name>"..." | :<class name> ]
Enable assertions. Assertions are disabled by default. With no arguments, enableassertions or -ea enables assertions.
Note 2:
An assertion is a statement in the JavaTM programming language that enables you to test your assumptions about your program.
Each assertion contains a boolean expression that you believe will be true when the assertion executes. If it is not true, the system will throw an error. public class AssertionError extends Error
Thrown to indicate that an assertion has failed.
Note 3:
The javac command compiles Java source code into Java bytecodes. You then use the Java interpreter - the java command - to interprete the Java bytecodes.
Reference:java - the Java application launcher
Reference:java.langClass AssertionError

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
Currently there are no comments in this discussion, be the first to comment!
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago