Java Interface
Date: Apr 2014
Level: Basic


INTERVIEW QUESTIONS

Company: TATA Consultancy Services
Question Title: Java Interface
Language: Java
QUESTION DETAILS:

There are two interfaces A , B which contains the same method method foo() and Fonts class implements A & B.
Which interface method should the Fonts class implement - A or B?


Overridden method will be applicable for both the interfaces. Here's one example. This will produce the following output:
Hello
Hello
interface A
{
	public void foo();
}
interface B
{
	public void foo();
}
public class Fonts implements A,B {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		A a=new Fonts();
		a.foo();
		B b=new Fonts();
		b.foo();
	}
	@Override
	public void foo() {
		System.out.println("Hello");
}
}
All Questions