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 ?

Answers were Sorted based on User's Feedback



can you create interface instance ?..

Answer / sanddep

what uday did here was not creating the instance of the interface but he implemeted the interface through the anonymous class.Now the instance created is of that anonymous class which has implemented the interface and its reference is stored in the variable t.

Regards
Sandeep

Is This Answer Correct ?    1 Yes 0 No

can you create interface instance ?..

Answer / jenith michael raj

This is simply anonymous inner class, he implements the
interface in that class, that is why its working

Is This Answer Correct ?    1 Yes 0 No

can you create interface instance ?..

Answer / shankar patil

You can't create an object without method implementations.
Anonymous inner classes allow you to do.

public interface MyInterface {
public void myMethod() ;
}

MyInterface myIntfObj = new MyInterface() {
public void myMethod() {
}
};

myIntfObj.myMethod();

Is This Answer Correct ?    1 Yes 0 No

can you create interface instance ?..

Answer / ravi jain

In my point of view Uday is wrong..

In his code he creates a anonymous class that implements Test
interface.

so, we can't say this is an object of interface.

Is This Answer Correct ?    1 Yes 0 No

can you create interface instance ?..

Answer / anonymous

Hi Uday,

That's really nice however I think you have just created and anonymous class implementing the interface, and then invoking the wish method :)

Is This Answer Correct ?    1 Yes 0 No

can you create interface instance ?..

Answer / ramu

hey uday u r wrong
In your program you are not created obj for interface, you have given anonymous implementation for 'Test' interface and instantiated that anonymous class only but not the interface.
for conformation call getClass() on 't'.(t.getClass())

Is This Answer Correct ?    1 Yes 0 No

can you create interface instance ?..

Answer / amit singh

it was just a bullshit you did man
you are creating jus he anonymmous class and is just treate
a subclass of the paricular inerface and also the override
mehod execute
learn java because prople like you just amajed those people
those don' know java
so try your self first thing that java is the whole thing
which realed to Object class not he object so learn it

Is This Answer Correct ?    0 Yes 0 No

can you create interface instance ?..

Answer / manikandansit

hello Anil,

jus encourage who posts the answer but don;t do it over,why
because new one thinks that answer is correct instead of
wrong ok.

Is This Answer Correct ?    0 Yes 0 No

can you create interface instance ?..

Answer / neeraj

if we implements a class with an Interface then it will
compile time error i.e U must give the body of a method in
your class , so it is an anonymous class.We cannot create
Instance of an Interface.

Is This Answer Correct ?    0 Yes 0 No

can you create interface instance ?..

Answer / syed

My dear uday can u please create an instance of Abstract class but I think u cant create an instance of Abstract class

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Core Java Interview Questions

23. Storage space in java is of the form Stack Queue Heap List 24. What is java code embedded in a web page known as Applets Servlets scriptlets snippets 25. Which of the following attributes are compulsory with an <applet> tag?. code,height & width. 26. What does 'CODEBASE' in an applet tag specify?. Files absolute path.

0 Answers   TCS,


To what value is a variable of the Boolean type automatically initialized?

3 Answers  


Can we override compareto method?

0 Answers  


What is the role of garbage collector in java?

0 Answers  


whether java is fully object oriented language or partially object oriented language

4 Answers   Infosys, ME, SMK,


List the different types of classloaders in java.

0 Answers  


what is the use of pojo (plain old java objects)? how it is interact with crystal reports? pls urgent

0 Answers  


Explain the difference between scrollbar and scrollpane?

1 Answers  


WHAT IS MARKER INTERFACE,AND NO METHODS IS NOT THERE ON THAT INTERFACE THEN WHY WE USED IN JAVA?

3 Answers   L&T,


String is an immutable object. Then how can the following code be justified. String s1 = ?ABC?; String s1 = s1+?XYZ?; s.o.p(s1); The output is ABCXYZ, which is the value of s1 ?

6 Answers   Flextronics, Keane India Ltd,


What is passing parameters in java?

0 Answers  


Difference between Linked list and Queue?

0 Answers   Virtusa,


Categories