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 |
how ahstraction is the property of oops,this is also in c and c++ ex. printf function which is also hide the unnecessary data,so what is the difference ? and does c++ fallow the abstraction?
What is stateful in java?
What are the rules regarding quotation marks?
What does el mean in java?
Is java built on c?
What is a singleton in java?
What about javascript? : java security
Can the main method be declared final?
What is jsr in java?
What is exe file in java?
what is the function of OS
Do I need jdk or jre?