please solve the java puzzle and give soiution with reason

what wil be the output for this. please help me...

abstract class test

{

abstract void add(int x,int y);

}

interface inter

{

void add(int x,int y);

}

class testMain extends test implements inter

{

public static void main(String arg[])

{

public void add(int x,int y)

{

system.out.println(x+y);

}

}

testMain t=new testMain();

t.add(2,4);

}

}

my doubt is what wil call either abstract class or interface.

i don`t know the answer.

please help me.

thanking you java tiger

[626 byte] By [Passionate_Java_Lover_Vijaya] at [2007-11-27 5:58:12]
# 1
> what wil be the output for this.Run it and see.
pbrockway2a at 2007-7-12 16:32:27 > top of Java-index,Java Essentials,New To Java...
# 2

When (or if) you deal with the syntax problems and repost, could you use the "code" tags? They are described here: http://forum.java.sun.com/help.jspa?sec=formatting

The idea is that you put [code] at the start of your code and [/code] at the end. That way your code remains readable when it appears in the forum.

For instance:

[code]if(tagsUsed) {

outputGood = true;

}[/code]

will appear like:

if(tagsUsed) {

outputGood = true;

}

pbrockway2a at 2007-7-12 16:32:27 > top of Java-index,Java Essentials,New To Java...
# 3

Your code has lot of errors i have edited it.

abstract class test

{

abstract void add(int x,int y);

}

interface inter

{

void add(int x,int y);

}

class testMain extends test implements inter

{

public static void main(String arg[])

{

/*

public void add(int x,int y)

{

system.out.println(x+y);

}

*/

testMain t=new testMain();

t.add(2,4);

}

/*

testMain t=new testMain();

t.add(2,4);

*/

public void add(int x,int y)

{

System.out.println(x+y);

}

//}

}

Just go through the code and try to get the which one abstract class or interface is used.just try out by commenting and compiling code over and over again,you will find the answer!

Good luck

ram102125.

ram102125a at 2007-7-12 16:32:27 > top of Java-index,Java Essentials,New To Java...
# 4
> my doubt is what wil call either abstract class or> interface. How does one "call" an interface? Or an abstract method for that matter? What's the difference between calling something and implementing something?
petes1234a at 2007-7-12 16:32:27 > top of Java-index,Java Essentials,New To Java...
# 5

> What's the difference

> between calling something and implementing something?

What's the difference between using a car and builing a car?

This "calling interface" is complete BS. You're invoking a method on an instance of a concrete class stored in a reference. A reference who's type may be an interface or an abstract class or whatever. So you're not "calling an interface".

CeciNEstPasUnProgrammeura at 2007-7-12 16:32:27 > top of Java-index,Java Essentials,New To Java...
# 6
very thank you man.i just new to java. so i created my doubt with lot of error. thank you very much.
Passionate_Java_Lover_Vijaya at 2007-7-12 16:32:27 > top of Java-index,Java Essentials,New To Java...