Java interface reference

Java interface reference

When can an object reference be cast to an interface reference?
View Answers

October 27, 2010 at 3:48 PM

Hi,

Here is the answer.

An object reference be cast to an interface reference when the object implements the referenced interface.

Thanks.


August 4, 2012 at 12:53 PM

Yes it is possible.The class which you want to cast,it should be implemented that interface . Example:

List<String> list=new ArrayList<String> ();

List is interface, and arraylist is implemented by list. so that we can cast it into list reference.









Related Tutorials/Questions & Answers:
Java interface reference
Java interface reference  When can an object reference be cast to an interface reference
Java reference
Java reference  What is weak reference in Java
Advertisements
Is Java pass-by-reference?
Is Java pass-by-reference?  Is Java pass-by-reference
pass method reference in java
pass method reference in java  How to pass method reference in Java
Java interface
Java interface  What is the List interface
Java Interface
Java Interface  Can an Interface have an inner class?  Yes, interface can have inner class. for example- public interface gyan { static...("in interface"); }; public static void main(String args
Reference passing in java
Reference passing in java  plz tell me wat d meaning of refernce in java? for example : Class M(){ N n; } Class N(){ } wats dis meaning
Pass by Reference - Java Beginners
by Reference?can u please explain with examples.is java supports Pass by reference...); } } Java programming language does not pass objects by reference...(i); display(i); } } Pass By Reference: It refers to pass an object
Java interface
Java interface  What must a class do to implement an interface?  It must provide all of the methods in the interface and identify the interface in its implements clause
Java interface
Java interface  What modifiers may be used with an interface declaration
difference between hashcode,reference in java
difference between hashcode,reference in java  difference between hashcode,reference in java
Interface in java
Interface in java  An Interface method implemented in more than one different class with same method name. To avoid overriding of methods, we use ObjectReference for that class
java interface
java interface  Create a interface called student Define methods like get roll number Get name Get subject Create two classes Electronic student And history student Enter 5 students in the main class 2 of history and 3 elec
reference
reference of student into person can do like this or any other alternative Student
java pass by reference
java pass by reference  i understood java always pass arguments by pass by value so that the original value does not change...... but i want to know how we change the value and make it effect the original value by passing
pass by value /reference - Java Beginners
pass by value /reference  hello sir/mam, i know pass by value is a primitive type in java. what about pass by reference in java ? .. For object type pass by value is used or pass by reference is used ? pls give me a example
Marker Interface,Java Marker Interface
Interface in Java       In this section we will learn about Interface and Marker Interfaces in Java.... Electric switch is also the interface's example. But in java programming language
java call by reference - Java Beginners
affect the caller?s original variables. Java never uses call by reference. Java...java call by reference  in java do we have ane term like call by reference. if yes give me the full description with example and if no then also
Interface - Java Interview Questions
Interface  Respected sir why we use Interface in java? because we... a new interface, you are defining a new reference data type. You can use... a reference variable whose type is an interface, any object you assign to it must
Interface - Java Beginners
Interface in Core Java  What is Interface? How Can i Use Interface in Core Java
interface - Java Beginners
Interface definition language example  example of interface definition  If it is a Class --> Interface is implemented. A class may implement multiple interfaces.if it is an Interface --> Interface can be extended
Java cloneable interface
Java cloneable interface  What is cloneable interface
interface.
interface.  Write short note on interface.   Please visit the following link: Java Interface
Java Serializalble interface
Java Serializalble interface  What is the difference between Serializalble and Externalizable interface
interface - Java Beginners
interface  how to build interface in java programming language
Interface in Java
Interface in Java Interface in java programming languages is a collection... oriented concept. Through interface only abstraction is achieved in java. Syntax... is achieved in  Java. In an interface, only abstract method can be declared
Java Interface
Java Interface In this section we will discuss about the interface in Java... or more than one interfaces. Interface in Java is created for referencing something to other. To create an interface in Java the keyword "interface"
interface variables - Java Beginners
interface variables  why interface variable is by default final? what was the necessisity to make it final? plz explain me with good java prog
interface - Java Beginners
interface  what is an interface? when we will we use an interface in java? what will achived using interface?  Hi friend, Interface : An interface is a named collection of method definitions (without
INTERFACE
INTERFACE  how interface support multiple inheritance in java
Reference type Vs Object type. - Java Beginners
Reference type Vs Object type.  Can anyone explain the exact difference between Reference and Object, how can i create a reference ? When exactly we have to use reference. Is this both terms interchangeble. Thanks
Java itrator interface
Java itrator interface  What is an Iterator interface?  An iterator over a collection. Iterator takes the place of Enumeration in the Java.... The iterator interface have these methods- boolean hasNext(); Object next
interface
interface  what the use of interface?   An interface is one... variables.Any class can implement(inherit)the interface and make use of the methods(functions) and variables within it. In java, multiple inheritance
What is the best reference to start learning Java?
What is the best reference to start learning Java?  Hi, I want to learn Java programming from start. I am CSE final year student and want to learn... reference to start learning Java? Thanks   Hi, Beginners can learn
What is the best reference to start learning Java?
What is the best reference to start learning Java?  Hi, I want to learn Java programming from start. I am CSE final year student and want to learn... reference to start learning Java? Thanks   Hi, Beginners can learn
What is the best reference to start learning Java?
What is the best reference to start learning Java?  Hi, I want to learn Java programming from start. I am CSE final year student and want to learn... reference to start learning Java? Thanks   Hi, Beginners can learn
What is the best reference to start learning Java?
What is the best reference to start learning Java?  Hi, I want to learn Java programming from start. I am CSE final year student and want to learn... reference to start learning Java? Thanks   Hi, Beginners can learn
What is the best reference to start learning Java?
What is the best reference to start learning Java?  Hi, I want to learn Java programming from start. I am CSE final year student and want to learn... reference to start learning Java? Thanks   Hi, Beginners can learn
What is the best reference to start learning Java?
What is the best reference to start learning Java?  Hi, I want to learn Java programming from start. I am CSE final year student and want to learn... reference to start learning Java? Thanks   Hi, Beginners can learn
how do you parse by reference in java(with JGrasp)
how do you parse by reference in java(with JGrasp)  i am a 1st year beginner in java programming(GR 10) at hillcrest High School in south Africa My question is how do you parse by reference in java(with JGrasp) please help me i
interface
interface   what is the use of marking interface
interface
interface  What is marker interface ?? what is its use in java programming?? is this us in programming ??Explain is implementation with code
INTERFACE - Java Interview Questions
INTERFACE  Why Use Interface in Java?i want region ?plz post answer   Hi Friend, Interfaces form a contract between the class... the methods of the interface are implemented with the correct signature.Interfaces
Abstract class and interface in Java
Abstract class and interface in Java  What is the difference between abstract class and interfaces in Java?   Differences between an interface and an abstract class: At the same time multiple interfaces can
interface - Java Beginners
Interface meaning in java  What is the meaning of Interface? and why we need to call
Java simple reference source - Java Beginners
Java simple reference source  Hi, please could you recommend me a Java simple reference source (on line or e-book) where I could quickly find... would like to have a Java reference source for a quick look. I have got some
Interface in Java
Interface in Java       In this section we will learn about Interface and Marker Interfaces in Java.... Electric switch is also the interface's example. But in java programming language
interface
interface  why do we need interface in java..if it`s usefull for to obtain multiple inheritance in the sense how it gonna be achieved...and i can...)...the y we need interface...THis is question often i heard from my developer
interface - Java Beginners
interface  I need the complete program for Design of java interface for Stack ADT and implement the same using array and linked list in java. Kindly send it as soon as possible. SOme of your solutions are not accessible
Interface
for Interface in java? and want to know why they used interface instead of multiple inheritance? Thanks in advance   An interface is one which has abstract... method it will take.It creates complexity.Therefore java uses Interface

Ads