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

The Archive Base Latest Questions

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

I have a interesting scenario that. public class Base { public void hello(){ this.say();

  • 0

I have a interesting scenario that.

public class Base {

    public void hello(){
        this.say();
        System.out.println("hello-Base");
    }

    protected void say(){
        System.out.println("say-Base");
    }
}



public class Derived extends Base {

    public Derived(){
        super.hello();      
    }

    public static void main(String[] args) {
        Derived d = new Derived();      
    }

    public void say(){
        System.out.println("say-Derived");
    }

}

The output given is that:

say-Derived
hello-Base

I was expecting that when super.hello() method was invoked, say() method of Base classes was invoked rather than say()method of Derived class.

What is the reason behind this logic?

  • 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-15T10:11:46+00:00Added an answer on June 15, 2026 at 10:11 am

    Super.hello() calls this.say() which(this) refer to the current object i.e. derived so it calls the say method of derived class.

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

Sidebar

Related Questions

I have an interesting question on initialization. I have the following code: public class
I have an interesting situation that EMF forced me into: abstract class AbstractDog{ ...
I have an interesting scenario and the answer isn't jumping out at me. I've
I have the following interesting scenario: The test system, in my case BogusGateway of
I currently have this environment on my project: public abstract class Foo { private
I have an interesting scenario. I have a custom TableViewCell class which contains a
I have an interesting scenario that I need assistance with. I have a classic
I have an interesting scenario. I have a task model which has a task
I'm using SQL Server 2008. I have an interesting scenario where a stored procedure
I have the following interesting scenario: I've install ruby 1.9.2 via RVM and 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.