Under what circumstances an object reference be cast to an
interface reference?

Answer Posted / muthusenthil

when a class implements an interface then an object
referance of that class can be casted to interface referance

class A implements B{

public static void main(String args[]){
B b=new A();

}

Is This Answer Correct ?    6 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to run a JAR file through command prompt?

993


What is method with example?

815


What do you mean by inner class in java?

796


What are static methods?

833


I want to control database connections in my program and want that only one thread should be able to make database connection at a time. How can I implement this logic?

897


How do you override a variable in java?

779


Which collection does not allow duplicates in java?

745


Which class contains a method: cloneable or object?

804


What is the difference between an argument and a parameter?

789


Can we use both this () and super () in a constructor?

815


What is the base class in java from which all classes are derived?

774


What do you mean by checked exceptions?

771


What are examples of modifiers?

746


Are arrays passed by reference in java?

721


What is finalize()? Is finalize() similar to a destructor?

777