Java OCA OCP Practice Question 186

Question

Consider the following code. Which line will not compile?

1. Object ob = new Object(); 
2. String[] stringarr = new String[50]; 
3. Float floater = new Float(3.14f); 
4. ob = stringarr; 
5. ob = stringarr[5]; 
6. floater = ob; 
7. ob = floater; 
  • A. Line 4
  • B. Line 5
  • C. Line 6
  • D. Line 7


C.

Note

Changing an Object to a Float is going "down" the inheritance hierarchy tree, so an explicit cast is required.




PreviousNext

Related