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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:46:04+00:00 2026-06-15T13:46:04+00:00

There are three opcodes to invoke Java methods. It is clear that invokeStatic is

  • 0

There are three opcodes to invoke Java methods. It is clear that invokeStatic is just for static method invocation.

As far as I know invokespecial is used when invoking constructor and private methods. So, do we need to differenticate private and public method invocation at run time? It could be invoked with same opcode say invokevirtual?

Does JVM deals with private and public method definition? As far as I know public and private keywords is just needed at development phase for encapsulation?

  • 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-15T13:46:04+00:00Added an answer on June 15, 2026 at 1:46 pm

    http://www.artima.com/underthehood/invocationP.html
    The link above gives valuable examples clearly which addresing my question.

    class Superclass {
    
        private void interestingMethod() {
            System.out.println("Superclass's interesting method.");
        }
    
        void exampleMethod() {
            interestingMethod();
        }
    }
    
    class Subclass extends Superclass {
    
        void interestingMethod() {
            System.out.println("Subclass's interesting method.");
        }
    
        public static void main(String args[]) {
            Subclass me = new Subclass();
            me.exampleMethod();
        }
    }
    

    When you invoke main() in Subclass as defined above, it must print “Superclass’s interesting method.” If invokevirtual were used, it would print “Subclass’s interesting method.” Why? Because the virtual machine would choose the interestingMethod() to call based on the actual class of the object, which is Subclass. So it will use Subclass’s interestingMethod(). On the other hand, with invokespecial the virtual machine will select the method based on the type of the reference, so Superclass’s version of interestingMethod() will be invoked.

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

Sidebar

Related Questions

There are three Timer classes that I am aware of, System.Threading.Timer , System.Timers.Timer ,
I know there are three ways to change the view in iOS 1. [self
In x86 architecture there are one, two and three byte opcodes. What about ARM?
There are three classes - Children , Father , and Ancestor . Children extends
There are three files lay at с:/catalog. They are lib.dll, conf.ini,libImp.cpp. And I call
There are three parties in my design: MSFT orderbook NASDAQ index (need to be
There are three columns of cost, participant, single_cost and wants to write SQL to
There are three tables in my database: apples, refrigerators, and houses. Each apple belongs
There are three UIView *view1,view2 , view3; Now, view1 have to be shown at
Newbie question: There are three types of Asp.Net controls : HTML server controls, Web

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.