javascript
Brief description  about Online courses   join in Online courses
View Saranya  K 's Profile

Problem with using 3-interfaces

helo sir,
Suppose tat we use 3 different interfaces to print 3 statements,how to implement all tat in a single class. i get error wen i tried implementing it.. i am attaching the code that i tried out plz do help wth it.

CODE:


public interface nam
{
public void name();
}


public interface qual
{
public void qual();
}


public interface coll
{
public void coll();
}



class intrf implements nam,qual,coll
{
String name;
String qualif;
String coll;

public void nam(String x)
{
name=x;
System.out.println("My Name is:" name);
}
public void qual(String y)
{
qualif=y;
System.out.println("My Qualification is:" qualif);
}
public void coll(String z)
{
coll=z;
System.out.println("My College is:" coll);
System.out.println("I am a Java Programmer");
}
public static void main(String args[])
{
intrf in=new intrf();
in.nam("Saran");
in.qual("B.Tech");
in.coll("Anna Univ");
}

}

*****

please help me out in this..
Asked by Saranya K | Jul 18, 2012 |  Reply now
Replies (7)
View saranya k 's Profile
ya thank yu.. its clear nw.
Jul 20, 2012
View saranya k 's Profile
i tried modifying it too.. i get an error stating "the interface and method is nt abstract".. y is tat??
Jul 20, 2012
View rakesh kumar gupta 's Profile
import java.io.*;
interface nam
{
abstract void name();
}
interface qul
{
abstract void qual();
}
interface col
{
abstract void coll();
}

class Intrf implements nam,qul,col
{
public void name()
{

System.out.println("My Name is");
}
public void qual()
{

System.out.println("My Qualification is:");
}
public void coll()
{
System.out.println("I am a Java Programmer");
}
public static void main(String args[])
{
Intrf in=new Intrf();
in.name();
in.qual();
in.coll();
}
}
see in above example simply i use 3 different interfaces to print 3 statements in a single class now you can modify according to you and also can find mistake done by you
Jul 20, 2012
View saranya k 's Profile
Thank yu Rahul
Jul 20, 2012
View saranya k 's Profile
Thank yu Nitoo..
Jul 20, 2012
View rakesh kumar gupta 's Profile
Correct your Method name first it should be name not nam
Jul 19, 2012
View n n n 's Profile
Hi,

When you override methods in interface, you need to make sure the signature of the interface methods and the same return type are maintained.
Jul 19, 2012