Home TechnologyProgrammingJava Subscribe to RSS

What Is Instance Of Class?

Answer Question

1 Answer - Sort by: Date | Rating

    It is an object that is created to achieve desired results even when observing encapsulation. For example:
    Variables and methods cannot be referenced from a static context and so when you want to use a variable constructed and initiated outside a static method, in a static method, you have to create an instance of that class in form of an object then call the variable using the object.
    Check:

    public Class MyDemo
    {
      String youGuy;

      public static void main (String [] args)
      {
         MyDemo theInstance = new MyDemo;
         theInstance.youGuy = "Guest, Who?";
         System.out.print (theInstance.youGuy);
      }
    }

    Instances can also be used when dealing with subclasses and superclasses.
    I hope this helps: Sorry it's freestyle!
    0 0

    Jamesy 

    answered 7 months ago

      More

         
         

        Ask a Question via Twitter

        Send a question to @askblurtit and we will publish it online and send you a reply everytime you receive an answer.

        Blurtit Store

        Get T-shirts, hoodies, caps and more at the Blurtit store

        Blurtit International