Java OCA OCP Practice Question 736

Question

A java source file contains the following code:

interface I  {  //from  ww w . ja v a2s  .  c  om
  int getI (int a, int b);  
} 

interface J{ 
    int getJ (int a, int b, int c); 
} 

abstract class MyInterface implements J , I  {  } 

class MyClass{  
    int getI (int x, int y){ return x+y;  } 
} 

interface K extends J{ 
    int getJ (int a, int b, int c, int d); 
} 

Identify the correct statements:

Select 1 option

  • A. It will fail to compile because of MyInterface
  • B. It will fail to compile because of MyInterface and K
  • C. It will fail to compile because of K
  • D. It will fail to compile because of MyClass and K
  • E. It will fail to compile because of MyInterface, K, and MyClass
  • F. It will compile without any error.


Correct Option is  : F

Note

MyInterface declares that it implements interfaces I and J, but does not implement the methods declared in these interfaces.

Since MyInterface has been declared as abstract, it is valid.




PreviousNext

Related