Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7902875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:37:03+00:00 2026-06-03T09:37:03+00:00

I just read in a document that A static method can call only other

  • 0

I just read in a document that “A static method can call only other static methods and can not call a non-static method from it”. But when I tried to test it I think saw something different.

I have a class C which is described below

import pckage1.*;

public class C
{

public static void main(String par[])
{       
}
public static void cc() 
{
    A ob = new A();
    ob.accessA(0);      
}   

}

where class A is

package pckage1;

public class A 
{
public A() 
{
}
public void accessA(int x)
{   
}

}

Now here from cc STATIC method in class C, a NON STATIC method accessA() is called. How could that be possible if the statement about static method is true?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T09:37:04+00:00Added an answer on June 3, 2026 at 9:37 am

    A static method can call only other static methods and can not call a non-static method from it

    That’s wrong.

    Static methods can call non-static methods as long as they have objects to call the methods on (as you discovered in your code snippet). How else would a non-static method ever be called?

    You can’t do nonStaticFoo() from a static method, since it is interpreted as this.nonStaticFoo() and since there is no this available in a static method.

    Very similar question from earlier today:

    • Static method access to non-static constructor?
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just read Factory Method. I understand that it provides a way to delegate
I'm now struggling with UIImagePicker. I've read the document but it seems not to
I'm new to jquery. I've just read that these 2 are equivalent: $(document).ready(function() {});
I just read about HTML 5's WebSocket interface. How can I start trying this?
I just read Spolsky's last piece about Distributed vs. Non-Distributed version control systems http://www.joelonsoftware.com/items/2010/03/17.html
I just read that C99 has double_t which should be at least as wide
I studied polymorphism and understand that it can do dynamic method binding like below.
I am trying to get a document from Excel or OpenOffice that contains UTF
I'm trying to read a MS Office Excel document so I can test a
I have a problem when using simplexml to read a xml document that I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.