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


Please Help Members By Posting Answers For Below Questions

What is a blocking method in Java?

826


Given a singly linked list, find the middle of the list in a single traversal without using temporary variable.

827


why doesn't java run on all platforms?

770


How do you declare a string variable?

737


why are wait(), notify() and notifyall() methods defined in the object class? : Java thread

741


How do you escape json?

759


Can a set contain duplicates?

709


Can we nested try statements in java?

844


Why main() method is public, static and void in java ?

832


What is the differences between heap and stack memory in java? Explain

730


what is abstract class in Java?

875


What is the default size of arraylist in java?

727


When would you use a static class?

749


What is a stringbuffer?

743


What is visibility mode?

725