• Sunday, August 31, 2014

    4 Java - Basic about Java Classes, Objects and Instance.

    JAVA Classes, Java Objects and its Instance

    Java Classes
    In Java, codes are written under a body called class.

    Example: a class with name "MyClass

    class MyClass



    Objects and Instance

    Objects are the real world character created in Java.
    It may be car, animal, home, etc...

    This class can be taken as object in other class as well as in their own class.

    When we take class as a object then its called a instance of a class.

    Object can be created by using this syntax: ClassName variableName = new ClassName();


    class Car

       public static void main(String args[])


         Car safari=new Car();




    Car is the name of class.

    safari is a variable, used to create a  instance of the class Car.

    new is keyword of Java used to make a new copy of any object.

      Prev: A Hello World Example    - Next: Creating Objects

    Syed Masoom Rizvi

    Author & Editor

    Hi, This is Syed Masoom Rizvi, who is continue exploring the world of programming ,programming and programming... :)


    Post a Comment