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 / mallesh

hey uday that is not creating intance for Test interface ,
ur implementing the interface using anonymous class
(unknoun class)

public class Test2 {

public static void main(String[] args) {
Test2 t=new Test2();
Runnable r=new Runnable() {
public void run() {
System.out.println("Hi");

}
}; r.run();
System.out.println(r.getClass().getName().toString());
System.out.println(t.getClass().getName().toString());

}
}

Output:Hi
Test2$1
Test2

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is difference between wait and notify in java?

1200


How many bits is a boolean?

1132


Can we define static methods inside interface?

1029


When will we use them?

1102


Do you know why doesn't the java library use a randomized version of quicksort?

990


Given a singly linked list, how will you print out its contents in the reverse order? Can you do it with consuming any extra space?

1044


Is array serializable java?

1049


What is an argument in java?

986


What is string [] args?

1059


What are keyboard events?

1207


Explain about public and private access specifiers?

1119


What is a dot notation?

1100


What are the two types of exceptions in java? Which are the differences between them?

1151


Is object a data type in java?

1156


What is parseint?

1071