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

  • Home
  • SEARCH
  • 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 8350535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T08:20:47+00:00 2026-06-09T08:20:47+00:00

Can I call a parent class overridden method with the child class object in

  • 0

Can I call a parent class overridden method with the child class object in java?

I tried below example

class First1
 {
   void show()
    {
    String msg="You are in first class";
    System.out.println(msg);
    }
 }   
 class second extends First1  
 {  
   void show()  
   {  
   String msg="You are in second class";  
   System.out.println(msg);          }  
   }  
 }
 class CallingMethod extends second  
 {  
   void show()  
   {  
    String msg="You are in the third class";  
    System.out.println(msg);  
   }  
    public static void main(String[] args)  
    {  
    CallingMethod cm=new CallingMethod();  
    cm.show();  
    }  

}

Now tell me if it is possible to print “I am in second class.” by using the object of CallingMethod class that is cm here in example and without using super keyword anywhere.

  • 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-09T08:20:49+00:00Added an answer on June 9, 2026 at 8:20 am

    I assume you mean to call the method from outside of the subclass.

    Then no, not possible in java, since an overriden method means changed behaviour that makes sense for the new class.

    Inside of the class, you would use the super keyword in any case.

    NOTE: using Reflection you can do things with objects, that the language itself does not allow.

    NOTE: I tested this using Reflection, it does NOT work. But when you use C with JNI you might be able to do that…

    //does not work
    class YourClass
    {
        public static void main(String[] args) throws SecurityException,
                NoSuchMethodException, IllegalArgumentException,
                IllegalAccessException, InvocationTargetException
        {
            CallingMethod cm = new CallingMethod();
            First1 f = new First1();
            // Method m = First1.class.getDeclaredMethod("show");
            Method m = First1.class.getMethod("show");
            m.invoke(f);
                        //output: You are in first class
            m.invoke(cm);
                        //output: You are in the third class
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I go about making a child class override a privileged method of
How to specify overridden method of which base class to call in Delphi? Let
(Yes I know I can call Java code from Scala; but that is pointless;
how I can call database stored procedure if someone is leaving page? For example,
Is there any way, in PHP, to call methods from a parent class using
I want to call a partial method from outside of the declaring class. This
I'm using the shapedrawable example word for word (nearly) and can't seem to call
As you can see in the code below, the DoStuff() method is getting called
class GrandParent { public virtual void Foo() { ... } } class Parent :
I wonder whether it's possible to access a method declared in a parent class,

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.