can you create interface instance ?
Answer Posted / udaykiran
Why Not?
Yes, Even we can create an instance of interface and
abstract class also.
just see this below simple example
Main.java
-----------
interface Test
{
public void wish();
}
class Main
{
public static void main(String[] args)
{
Test t=new Test()
{
public void wish()
{
System.out.println("output: hello how r u");
}
};
t.wish();
}
}
cmd> javac Main.java
cmd> java Main
output: hello how r u
in above case Test is an interface but i created the object
for that interface.
Is This Answer Correct ? | 54 Yes | 92 No |
Post New Answer View All Answers
what are Hostile Applets?
What is an exception? difference between Checked and Unchecked exception in Java
What is array size in java?
What is the use of static class?
What is e java?
What is __ init __ functions?
What is numel matlab?
Differentiate between class and structure.
what is meant by encapsulation?
How do you override a method?
Does apple use java?
What was java originally called?
What is the collections api?
Which is easier .net or java?
Write an algorithm program in java for the following question.. In a VLSI design techniques,they used rectangles to design circuits. EVery rectangle is to be placed according to x,y coordinates. Check whether or not two rectangles overlap each other. Here overlapping of rectangles is acceptable, if 1) one rectangle intersect with other. 2) one rectangle fully covers other. The time of algorithm should not exceed o(n logn).