cool hit counter
Cafe4Java
Cafe4Java
 

SCJP Mock Exam Answers
A2)
Answer : E
Explanation :
  • A) Option A is incorrect. Covariant returns are valid starting from J2SE5.0 for overridden methods. Prior to J2SE 5.0, an overriding method could not return a data type that is a subclass of the return type of the method defined in the Super class. Class 'SubCafe4Java' will fail to compile with the error 'attempting to use incompatible return type'. (String is a subclass of Object). However, covariant returns are valid in J2SE5.0.

  • B) Option B is incorrect. Covariant returns are valid starting from J2SE5.0 for overridden methods. Prior to J2SE 5.0, an overriding method could not return a data type that is a subclass of the return type of the method defined in the Super class. Class 'SubCafe4Java' will fail to compile with the error 'attempting to use incompatible return type'. (String is a subclass of Object). However, covariant returns are valid in J2SE5.0.

  • C) Option C is incorrect. Covariant returns are valid starting from J2SE5.0 for overridden methods. Prior to J2SE 5.0, an overriding method could not return a data type that is a subclass of the return type of the method defined in the Super class. Class 'SubCafe4Java' will fail to compile with the error 'attempting to use incompatible return type'. (String is a subclass of Object). However, covariant returns are valid in J2SE5.0.

  • D) Option D is incorrect. Covariant returns are valid starting from J2SE5.0 for overridden methods. Prior to J2SE 5.0, an overriding method could not return a data type that is a subclass of the return type of the method defined in the Super class. Class 'SubCafe4Java' will fail to compile with the error 'attempting to use incompatible return type'. (String is a subclass of Object). However, covariant returns are valid in J2SE5.0.

  • F) Option F is incorrect because the code fails to compile.

  • G) Option G is incorrect because the code fails to compile.


<<<< Return to Q2 <<<<<         >>>> Go to Q3 >>>>

Submit your feedback on this mock exam


 
 
Custom Search
     
Cafe4Java