Wednesday, 3 February 2016

Java Tutorial : Java Object Class(Assign subclass)


Click here to watch in Youtube :
https://www.youtube.com/watch?v=y-oMA--3BgQ&list=UUhwKlOVR041tngjerWxVccw

Click the below Image to Enlarge
Java Tutorial : Java Object Class(Assign subclass) 
Employee.java
public class Employee
{
    String name;    

}
Student.java
public class Student
{
    String name;
    int age;
}
ObjectClassTest.java
import java.util.ArrayList;


public class ObjectClassTest
{

    public static void main(String[] args)
    {
        Object objectRef = new Employee();
        System.out.println(objectRef);
        
        objectRef = new Student();
        System.out.println(objectRef);
        
        objectRef = new ArrayList<String>();
        System.out.println(objectRef);
        
        objectRef = new String("John");
        System.out.println(objectRef);

    }

}
Output
Employee@659e0bfd
Student@2a139a55
[]
John
Click the below link to download the code:
https://sites.google.com/site/javaee4321/java/ObjectClassDemo_Assign_Subclass_App.zip?attredirects=0&d=1

Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/ObjectClassDemo_Assign_Subclass_App

Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/8fa82bcbf36a8ef675302adced6f7a0764627bd4/BasicJava/ObjectClassDemo_Assign_Subclass_App/?at=master

See also:
  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • All JAVA EE Links
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • No comments:

    Post a Comment