Results 1 to 4 of 4
  1. #1
    javastuden's Avatar
    javastuden is offline Senior Member
    Join Date
    Nov 2009
    Posts
    162
    Rep Power
    5

    Default who call the class test2

    hi who the output is hello world
    class Test{
    public static void main(String[] ar){

    Test2.getValue();
    }
    }

    class Test2{
    public static void getValue(){
    System.out.println("hello world");
    }
    }

    who call the Test2 class to initilaize with out new operator
    please explain it detaily

  2. #2
    XmisterIS is offline Member
    Join Date
    Aug 2010
    Posts
    35
    Rep Power
    0

    Default


  3. #3
    javastuden's Avatar
    javastuden is offline Senior Member
    Join Date
    Nov 2009
    Posts
    162
    Rep Power
    5

    Default

    hi XmisterIS what u replied

  4. #4
    narayana is offline Member
    Join Date
    Sep 2010
    Posts
    1
    Rep Power
    0

    Default javaStuden

    In Test2 class you defined the method as static getValue()
    In java static members can be accessed with out object when ever it is coming to ---Test2.getValue() --- JVM automatically loads coresponding static members of class as you know


    That's it

Similar Threads

  1. how do i call a class from main class
    By revanger in forum New To Java
    Replies: 7
    Last Post: 07-20-2010, 05:32 PM
  2. Replies: 2
    Last Post: 05-01-2010, 08:59 AM
  3. How can I call abstract class methods from another class
    By srinivas2828 in forum New To Java
    Replies: 13
    Last Post: 03-12-2010, 02:33 PM
  4. need help to call another class
    By doha786 in forum New To Java
    Replies: 2
    Last Post: 03-08-2010, 10:40 AM
  5. How can I call method from class in other class??
    By Hisham in forum New To Java
    Replies: 6
    Last Post: 02-14-2010, 03:49 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •