when Can an object reference be cast to an interface reference?
Answer / praveen kumar
.An interface reference can point to any object of a class that implements this interface i.e. see the example below:
interface Foo{
void display();
}
public class TestFoo implements Foo{
void display(){
System.out.println(“Hello World”);
}
public static void main(String[] args){
Foo foo = new TestFoo();
foo.display();
}
}
| Is This Answer Correct ? | 0 Yes | 0 No |
Java prints out a ton of digits when I system.out.println() a double. How can I format it so it displays only 3 digits after the decimal place?
What is exe file in java?
What is stateless in java?
What are the types of cookies in java?
How do you run an executable jar file?
What is entitymanager in java?
What are the rules regarding quotation marks?
why the sleep method does not leave the lock and wait method leave the lock
what are the steps in JDBC connectivity..???
How do I enable java in google chrome?
What is default constructor in java?
Can I have multiple main methods in the same class?