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

Write a factorial program using recursion in java?

957


What does java stand for?

1048


Can you sort a list in java?

931


What is use of static method?

1001


What is instanceof keyword?

1174


What is the difference between arraylist and hashset in java?

1066


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

1003


What is the program compilation process?

1041


What do you understand by final value?

1008


Is java programming easy?

945


Why pass by reference is not possible in java?

969


What is string immutability?

1033


How do you remove spaces in java?

984


Is 0 a prime number?

936


What is meant by anonymous class?

981