Sponsored Links


Results 1 to 2 of 2

Thread: we can not call the non static methods from a sttic methods is it true statement??

  1. #1
    Senior Member saneha's Avatar
    Join Date
    Apr 2011
    Posts
    266

    Icon16 we can not call the non static methods from a sttic methods is it true statement??

    Sponsored Links1


    we can not call the non static methods from a sttic methods

    is it true statement???

    If so than how we are calling the methods from our main programme

    because main is static method

    Sponsored Links

    kindly clerify this point fully

    thanks

  2. #2
    Administrator Vuhelper's Avatar
    Join Date
    Apr 2011
    Posts
    9,578

    Icon20 we can not call the non static methods from a sttic methods

    Dear Student,

    All static methods work alike and you are not right in sense that we call non static method in static method by providing it a reference to the belonging object.
    e.g. look at following code:
    public class Main {

    /**
    * @param args the command line arguments
    */
    public static void main(String[] args) {
    // TODO code application logic here
    Main m1 = new Main();
    m1.disp1();
    NewClass.disp();
    }
    public void disp1(){
    System.out.println("its a non static method");
    }
    }
    public class NewClass {
    public static void disp(){
    System.out.println("its a static method");
    NewClass n1 = new NewClass();
    n1.disp1();
    }
    public void disp1(){
    System.out.println("its a non static method");
    }
    }
    Output:
    run:
    its a non static method
    its a static method
    its a non static method

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. The amicable/ peaceful methods of settlement are ideal.
    By vustudents in forum Public International Law LLB part 2
    Replies: 0
    Last Post: 09-07-2012, 02:19 AM
  2. between Get and Post methods
    By saneha in forum Java forum
    Replies: 1
    Last Post: 04-24-2011, 10:45 PM
  3. VU-MBA-1] Online Quiz # 01 of “Research Methods (STA630)
    By desireforheaven in forum Announcements
    Replies: 0
    Last Post: 10-29-2010, 10:30 PM
  4. STA630 Research Methods Quiz May 2010
    By viki in forum MCQ's & Quiz Discussion
    Replies: 0
    Last Post: 05-30-2010, 11:00 PM
  5. STA630 Research Methods Solution May 6, 2010
    By viki in forum Assignments & Solutions
    Replies: 0
    Last Post: 05-07-2010, 12:42 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
-: Vuhelp Disclaimer :-
None of the files shown here are hosted or transmitted by this server. The links are provided solely by this site's users. The administrator's or staff of Vuhelp.net cannot be held responsible for what its users post, or any other actions of its users. You may not use this site to distribute or download any material when you do not have the legal rights to do so. It is your own responsibility to adhere to these terms. If you have any doubts about legality of content or you have any suspicions, feel free to contact us.
Online Education | JhelumSoft | Jobs