ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   To Refer this Site to Your Friends   Click Here
Google
 
Categories  >>  Software  >>  Core Java  >>  Java J2EE  >>  Java Related
 
 


 

 
 Core Java interview questions  Core Java Interview Questions
 Advanced Java interview questions  Advanced Java Interview Questions
 Swing interview questions  Swing Interview Questions
 EJB interview questions  EJB Interview Questions
 Servlets interview questions  Servlets Interview Questions
 Struts interview questions  Struts Interview Questions
 JDBC interview questions  JDBC Interview Questions
 JMS interview questions  JMS Interview Questions
 SunOne interview questions  SunOne Interview Questions
 J2EE interview questions  J2EE Interview Questions
 Weblogic interview questions  Weblogic Interview Questions
 Websphere interview questions  Websphere Interview Questions
 Java Networking interview questions  Java Networking Interview Questions
 Java J2EE AllOther interview questions  Java J2EE AllOther Interview Questions
Question
Interface A {
String test();
}

Interface B {
int test();
}

Create a class AB which must implements both A & B 
interfaces.
 Question Submitted By :: Nitin
I also faced this Question!!     Rank Answer Posted By  
 
  Re: Interface A { String test(); } Interface B { int test(); } Create a class AB which must implements both A & B interfaces.
Answer
# 1
interface A
{
 String test();
}

interface B extends interface A
{
  int test();
}

public Class AB implements B

{

   public String test()
   {

     }

   public int test()
   {
     }

}
 
Is This Answer Correct ?    2 Yes 14 No
Sandeep Vudutala
 
  Re: Interface A { String test(); } Interface B { int test(); } Create a class AB which must implements both A & B interfaces.
Answer
# 2
we can not do with same method name. i tried it in jdk1.5,
not able to compile.
 
Is This Answer Correct ?    12 Yes 2 No
Chandra
 
 
 
  Re: Interface A { String test(); } Interface B { int test(); } Create a class AB which must implements both A & B interfaces.
Answer
# 3
Sandeep,
Interface B gets the compilation error saying, "The return 
type is incompatible with A.test()"

Hence, the proposed solution is not correct.
 
Is This Answer Correct ?    7 Yes 2 No
Nitin
 
  Re: Interface A { String test(); } Interface B { int test(); } Create a class AB which must implements both A & B interfaces.
Answer
# 4
yes , we cant implement like this.same as above answer.I 
tested it .
 
Is This Answer Correct ?    3 Yes 3 No
Ganesh
 
  Re: Interface A { String test(); } Interface B { int test(); } Create a class AB which must implements both A & B interfaces.
Answer
# 5
forget about implementing the interface
First of all can we can not have two similar method names 
only with return type as different.As per overloaded method 
concept it is not acceptable.So inorder to implement the 
interfaces we need to do like that which is not acceptable 
as per overloaded methods principle and hence compilation 
error.
 
Is This Answer Correct ?    5 Yes 2 No
Kssrk Ramesh
 
  Re: Interface A { String test(); } Interface B { int test(); } Create a class AB which must implements both A & B interfaces.
Answer
# 6
Ramesh,
I am agree with the technical boudries which you have 
talked about. But this is a real problem and have to cope 
with it.
We can not change the interfaces at all, but there should 
be a way to achieve the goal, may be using inner class or 
so.
 
Is This Answer Correct ?    0 Yes 1 No
Nitin
 
  Re: Interface A { String test(); } Interface B { int test(); } Create a class AB which must implements both A & B interfaces.
Answer
# 7
Chandan
test in A clashes with test in B;attempting to use 
incompatible type
 
Is This Answer Correct ?    0 Yes 1 No
Chandan Kumar
 
  Re: Interface A { String test(); } Interface B { int test(); } Create a class AB which must implements both A & B interfaces.
Answer
# 8
interface A
{
 String test();
}

interface B
{
  int test();
}


public class AB implements B

{

  	A obj1 = new A(){
	  public String test()
		{
			return "";
		}
  };
   public int test()
   {
	   return 0;
   }
}
 
Is This Answer Correct ?    4 Yes 6 No
Menita
 
  Re: Interface A { String test(); } Interface B { int test(); } Create a class AB which must implements both A & B interfaces.
Answer
# 9
Menita you are absolutely correct!!
 
Is This Answer Correct ?    0 Yes 5 No
Nitin Gupta
 
  Re: Interface A { String test(); } Interface B { int test(); } Create a class AB which must implements both A & B interfaces.
Answer
# 10
Interface A {
String test();
}

Interface B {
int test();
}

Class AB implements A,B
{
String test()
{
System.out.println("Test");
}
int test()
{ System.out.println("Test1");
}
}
Class Test
{
public static void main(String as[])
{
Interface i=null;

i=new AB();
i.test();
}
}
 
Is This Answer Correct ?    2 Yes 6 No
Sailaja
 
  Re: Interface A { String test(); } Interface B { int test(); } Create a class AB which must implements both A & B interfaces.
Answer
# 11
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 ?    2 Yes 3 No
Sumit
 
  Re: Interface A { String test(); } Interface B { int test(); } Create a class AB which must implements both A & B interfaces.
Answer
# 12
public class AB implements A,B
{
  public static void main(String args[])
{

}
}
 
Is This Answer Correct ?    0 Yes 3 No
Niltarlekar
 
  Re: Interface A { String test(); } Interface B { int test(); } Create a class AB which must implements both A & B interfaces.
Answer
# 13
Class AB Implements A,B{
String test(){
SOS("----");
}
int test(){
SOS("--------");
}
}
 
Is This Answer Correct ?    0 Yes 2 No
Srinivasa
 

 
 
 
Other Core Java Interview Questions
 
  Question Asked @ Answers
 
what is servlet filter?  1
AWT event listeners extends what interface?  1
Explain the relationship between the Canvas and Graphics class?  1
How to send a request to garbage collector?  3
Are nested try statements are possible?  2
How two different class threads communicate with each other?. send example code.  4
Can an anonymous class be declared as implementing an interface and extending a class?  1
What is the frontend and backedn in Java? TCS2
Difference between prefix and postfix forms of the ++operator?  2
Difference between canvas class & graphics class?  1
How a class can implement an interface? SysArc4
what is difference between abstract and interface? can i give real time example for the two topics?  6
What is the purpose of setAutoCommit() ? Google1
What JNDI(Java Naming and Directory Interface) provides?  4
what are the different access specifiers that can be used by interfaces and abstract classes? can anyone give me detailed description on this  7
What is object  6
What is adapter class?  2
what release of java technology are currently available what do they contain?  1
what modifiers are used with top-level class?  2
how to convert mm/dd/yy to dd/mm/yy using collections in java. Bosch2
 
For more Core Java Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com