Which statement is true about the interfaces and classes ?
public interface Service {
public void sum(int num1, int num2);
}
public class ServiceImpl implements Service{
@Override
public void sum(int num1, int num2) {
[Link]("sum method implementation");
}
}
public class ServiceBO {
public Service cal(){
return new ServiceImpl();
}
public String msg(){
return "Hi";
}
}
public class ServiceBoChild extends ServiceBO{
public ServiceImpl cal(){
return new ServiceImpl();
}
public Object msg(){
return "Hello";
}
}
A) Compilation of class ServiceImpl will fail.
B) All classes and interfaces will run successfully.
C) Compilation of class ServiceBoChild will fail because of an error in cal() method.
D) Compilation of class ServiceBoChild will fail because of an error in msg() method.
2. What is wrong with this code?
public final interface TestClass{
public static final int x=8;
public TestClass(){}
public TestClass();
public abstract void methodName(){ }
public abstract void methodName1();
}
3)
public interface TestClass{
public static final int x=8;
public abstract void methodName1();
}
public class TestClass1 implements TestClass{
int x=10;
public void methodName1(){
S.O.P(x);
}
}