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 are the restrictions imposed on method overriding?

961


What is included in core java?

1000


Which programming language is best in future?

890


Explain abstract class in java?

989


What a static class can contains?

1106


what is thread? What are the high-level thread states? Or what are the states associated in the thread? : Java thread

941


Why is it important to initialize a variable?

938


What is the symbol for space?

929


What is thread start?

913


Give differences between Quicksort &Mergesort. When should these sorts be used andwhat is their running time in java?

1169


What do you mean by platform independence? What is an interface?

981


How can a gui component handle its own events?

1042


What is %02d?

1037


What is the use of jtable?

1060


What do you understand by garbage collection in Java? Can it be forced to run?

915