Which Statement Is True About The Interfaces and Classes ?
The document defines an interface Service with a method sum, a implementing class ServiceImpl, and classes ServiceBO and ServiceBoChild that extend ServiceBO. ServiceBoChild overrides the cal() method from ServiceBO but not the msg() method, so compilation of ServiceBoChild will fail due to an error in the msg() method.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
47 views2 pages
Which Statement Is True About The Interfaces and Classes ?
The document defines an interface Service with a method sum, a implementing class ServiceImpl, and classes ServiceBO and ServiceBoChild that extend ServiceBO. ServiceBoChild overrides the cal() method from ServiceBO but not the msg() method, so compilation of ServiceBoChild will fail due to an error in the msg() method.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2
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) { System.out.println("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(); }