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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T04:47:47+00:00 2026-06-19T04:47:47+00:00

I have developed the below class as shown below class Ab { int i

  • 0

I have developed the below class as shown below

class Ab {
    int i = 10; 
    static void getF() {
        System.out.println("I am good");
    }
}
class Hamm extends Ab {
    int i = 10; 
    static void getF() {
        System.out.println("I am good and bad boy");
    }
    public static void main(String[] args) {
         //Hamm h = new Hamm();      
        // h.getF(); //Ham
        Ab a = new Hamm();  //reference of parent class
        //a.getF(); // Ab class

    }
}

Now my query is there any scenario exisits where I am getting the variable i of class Ab but the method getF() of class Hamm, Please advise.

  • 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-19T04:47:48+00:00Added an answer on June 19, 2026 at 4:47 am

    Declare the method to be non-static. You use it as instance method anyway. Static methods can not be overriden.

    Here is a working sample:

    class Ab {
        int i = 10; 
        void getF() {
            System.out.println("I am good");
        }
    }
    class Main extends Ab {
        int i = 10; 
        @Override
        void getF() {
            System.out.println("I am good and bad boy");
        }
        public static void main(String[] args) {
             //Hamm h = new Hamm();      
            // h.getF(); //Ham
            Ab a = new Main();  //reference of parent class
            a.getF(); // Ab class
    
        }
    }
    

    And a link on ideone.

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

Sidebar

Related Questions

In case of static method overriding ..I have developed this below code class Ab
I have developed below which makes the use of comparator.. this my pojo.. class
I have the class below. _commandLine variable is declared as static. Does this variable
C# 2008 I have developed the class below. I have to get the balance
i have been developed my last project like below as by last architecture View
I have developed this custom ImageView class to override some of the default behavior
I have developed the below program but it is throwing null pointer exception. Below
I have developed a below code based on the concept of immutability , as
I have just started to develop the form below and I have the following
I want to develop cross platform mobile app. I have seen frameworks listed below

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.