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 7922343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T16:55:08+00:00 2026-06-03T16:55:08+00:00

My Assumptions : Static method cannot cannot call non-static methods. Constructors are kind of

  • 0

My Assumptions:

  1. Static method cannot cannot call non-static methods.
  2. Constructors are kind of a method with no return type.

Given this example…

    public class Main {
        public static void main(String[] args) {
            Main p = new Main();  // constructor call
            k();  // [implicit] `this` reference
        }

        protected Main() {
            System.out.print("1234");
        }

        protected void k() {
        }
    }
  • this line prints 1234: Main p = new Main()
  • this line throws an Exception: k()

Why did the example code do those two things? Don’t they conflict with my above Assumptions? Are my Assumptions correct?

  • 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-03T16:55:09+00:00Added an answer on June 3, 2026 at 4:55 pm

    1 – Static method cannot cannot call non-static methods.

    Sure they can, but they need an object to call the method on.

    In a static method, there’s no this reference available, so foo() (which is equivalent to this.foo()) is illegal.

    2 – Constructors are kind of a method with no return type.

    If they should be compared to methods, I would say constructors are closer to non-static methods (since there is indeed a this reference inside a constructor).

    Given this view, it should be clear to you why a static method can call a constructor without any problems.


    So, to sum it up:

    Main p = new Main();
    

    is okay, since new Main() does not rely on any existing object.

    k();
    

    is not okay since it is equivalent to this.k() and this is not available in your (static) main method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a call to an MVC controller method. The return type is FileStreamResult.
I have a static utility class, FileUtils which has the following method: public static
Here are my basic assumptions: Wcf executes my service operation methods on IOCP threads
Given an unsorted integer array, and without making any assumptions on the numbers in
Assumptions Suppose I have a class with a property: class ClassWithProperty { public string
For some static methods I realise it is extremely convenient to use a small
There appears to be no easy answer to this, but are there any assumptions
Can you help explain how multiple threads access static methods? Are multiple threads able
This is the piece of code in base C: static bool is_ascii_value_of_digit(char ascii_value){ if((ascii_value<40)&&(ascii_value
I want to select the right generic method via reflection and then call it.

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.