Click here to watch in Youtube :
https://www.youtube.com/watch?v=ykKLRR7aBx0&list=UUhwKlOVR041tngjerWxVccw
Click the below Image to Enlarge
Java Tutorial : Java instanceOf Operator |
public interface Employee
{
}
public class Parent implements Employee { private String name; private String age; public String getName() { return name; } public void setName(String name) { this.name = name; } public String getAge() { return age; } public void setAge(String age) { this.age = age; } }
public class Child extends Parent { private String schoolName; public String getSchoolName() { return schoolName; } public void setSchoolName(String schoolName) { this.schoolName = schoolName; } }
class InstanceOfOperatorDemo { public static void main(String[] args) { Parent parentObject = new Parent(); Parent childObject = new Child(); System.out.println("parentObject instanceof Parent: " + (parentObject instanceof Parent)); System.out.println("parentObject instanceof Child: " + (parentObject instanceof Child)); System.out.println("parentObject instanceof Employee Interface: " + (parentObject instanceof Employee)); System.out.println(); System.out.println("childObject instanceof Parent: " + (childObject instanceof Parent)); System.out.println("childObject instanceof Child: " + (childObject instanceof Child)); System.out.println("childObject instanceof Employee Interface: " + (childObject instanceof Employee)); } }
parentObject instanceof Parent: true parentObject instanceof Child: false parentObject instanceof Employee Interface: true childObject instanceof Parent: true childObject instanceof Child: true childObject instanceof Employee Interface: true
https://sites.google.com/site/javaee4321/java/OperatorsDemoInstanceOfApp.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/OperatorsDemoInstanceOfApp
Bitbucket Link:/span>
https://bitbucket.org/ramram43210/java/src/445777649bb0659322badeabdb5f7ba017537917/BasicJava/OperatorsDemoInstanceOfApp/?at=master
See also:
No comments:
Post a Comment