Java OCA OCP Practice Question 114

Question

Given:

4. class MyClass { 
5.   public static void main(String[] args) { 
6.     for(int __x = 0; __x < 3; __x++) ; 
7.     int #lb = 7; 
8.     long [] x [5]; 
9.     Boolean []ba[]; 
10.   } 
11. } 

What is the result?

Choose all that apply.

  • A. Compilation succeeds
  • B. Compilation fails with an error on line 6
  • C. Compilation fails with an error on line 7
  • D. Compilation fails with an error on line 8
  • E. Compilation fails with an error on line 9


C and D are correct.

Note

Variable names cannot begin with a #, and an array declaration can't include a size without an instantiation.

The rest of the code is valid.

A, B, and E are incorrect.




PreviousNext

Related