Java OCA OCP Practice Question 254

Question

Given two files:

1. class One {//from w w  w .jav a  2  s . c o  m
2.   public static void main(String[] args) {
3.     int assert = 0;
4.   }
5. }

1. class Two {
2.   public static void main(String[] args) {
3.     assert(false);
4.   }
5. }

And the four command-line invocations:

javac -source 1.3 One.java
javac -source 1.4 One.java
javac -source 1.3 Two.java
javac -source 1.4 Two.java

What is the result?

Choose all that apply.

  • A. Only one compilation will succeed
  • B. Exactly two compilations will succeed
  • C. No compiler warnings will be produced
  • D. Exactly three compilations will succeed
  • E. All four compilations will succeed
  • F. At least one compiler warning will be produced


B and F are correct.

Note

class One will compile and issue a warning using the 1.3 flag.

class Two will compile using the 1.4 flag.




PreviousNext

Related