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...

can you create interface instance ?

Answer Posted / yousif mustafa

I think UDAY is right and he gave the right answer.
We actually couldn't instantiate the interface but we could
instantiate object from class implements this interface and
override all of its methods due to interfaces could only
have abstract methods, but also we can use anonymous inner
class to do that and must override all the abstract method
within creating the object. for ex:

interface Test {
void printA();
void printB();
}

class Inter implements Test {
@Override
void printA() {System.out.println("A from implement");}
void printB() {System.out.println("B from implement");}
}

public class A {
public static void main (String arg[]) {
Test t = new Test() {
void printA() { System.out.println("A form inner"); }
void printB() { System.out.println("B from inner"); }
};
Inter i = new Inter();
t.printA();
i.printA();
t.printB();
i.printB();
}
}

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do you check if two strings are equal in java?

967


What do you understand by Header linked List?

1028


Can you override private or static method in java?

929


What is the difference between a factory and abstract factory pattern?

1082


What is json parser in java?

1003


Write a program to find the whether a number is an Armstrong number or not?

953


What is a text string?

1036


How garbage collection is done in java?

984


List some oops concepts in java?

978


Outline the major features of java.

1031


How do I write a self declaration?

1012


What is a website container?

896


What is the mapping mechanism used by java to identify IDL language?

954


What are wrapped classes in java programming?

1017


What is the difference between heap and stack memory?

1134