Interface A {
String test();
}
Interface B {
int test();
}
Create a class AB which must implements both A & B
interfaces.
Answer Posted / sumit
interface A {
String test();
}
interface B {
int test();
}
class AB implements A
{
public String test()
{ System.out.println("Test1 in AB");
return "a";
}
}
class Test
{
public static void main(String as[])
{
AB i = new AB();
B b = new B(){
public int test()
{
System.out.println("Test");
return 1;
}
};
i.test();
b.test();
}
}
| Is This Answer Correct ? | 3 Yes | 5 No |
Post New Answer View All Answers
How do you create immutable object in java?
How many times finalize method will be invoked? Who invokes finalize() method in java?
how is final different from finally and finalize in java?
What are inner classes or non static nested classes in java?
Can anonymous class have constructor?
What is thread safe singleton?
What are keywords and reserved words in java?
What is variable and its types?
What is native code?
What is regex in java?
what is the role of xml in core java?? and how we can use it?? can somebody give a sample program with explanation and from where i can read more about xml?????
How do you avoid global variables?
What are different types of states exist for a thread?
What is internal iteration in java se 8?
What is linked hashset and its features?