Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

did interface can implementation method ? i know its not
possible but my interviewer said its possible ..but how..?
any one have idea ???

Answer Posted / arpan mondal

Yes, an interface can if it has a class in it.

Here is the code what i am trying to say...

// MethodImplementedInterface.java
/**
*@author Arpan Mondal(www.arpanmondal.tk)
*/

interface A {
public class B {
B() {
display();
}
public void display() {
System.out.println("This is the
method in the interface.");
}
}
}

class C implements A {
B objB = new B();
void display() {
System.out.println("This is the method in
the class.");
}
}
public class MethodImplementedInterface {
public static void main(String[] args) {
C objC = new C();
objC.display();
}

}

The output of the above code is here...

This is the method in the interface.
This is the method in the class.

Is This Answer Correct ?    10 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do you remove an object from an arraylist in java?

904


What do you understand by looping in java? Explain the different types of loops.

997


Which is better list or arraylist in java?

808


Can we override constructor?

968


What is a qualifier in a sentence?

925


What is map and hashmap in java?

1026


Can we serialize singleton class?

973


Is list thread safe in java?

873


Is it safe to install java on my computer?

1044


How do I stop concurrentmodificationexception?

969


What is map in java?

943


Why you should not use singleton?

918


Can we cast any other type to boolean type with type casting?

892


What does function identity () do?

915


What is the difference between post and put?

993