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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T14:40:47+00:00 2026-06-02T14:40:47+00:00

When I make my own Android custom class, I extend its native class. Then

  • 0

When I make my own Android custom class, I extend its native class. Then when I want to override the base method, I always call super() method, just like I always do in onCreate, onStop, etc.

And I thought this is it, as from the very beginning Android team advised us to always call super on every method override.

But, in many books I can see that developers, more experienced than myself, often omit calling super and I really doubt they do it as a lack of knowledge. For example, look at this basic SAX parser class where super is omitted in startElement, characters and endElement:

public class SAXParser extends DefaultHandler{
    public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
        if(qName.equalsIgnoreCase("XXY")) {
            //do something
        }
    }

    public void characters(char[] ch, int start, int length) throws SAXException {
        //do something
    }

    public void endElement(String uri, String localName, String qName) throws SAXException {
        if(qName.equalsIgnoreCase("XXY")) {
            //do something
        }else () {
            //do something
        }
    }
}

If you try to create any override method via Eclipse or any other IDE, super will always be created as a part of automated process.

This was just a simple example. Books are full of similar code.

How do they know when you must call super and when you can omit it calling?

PS. Do not bind to this specific example. It was just an example randomly picked from many examples.

(This may sound like a beginner question, but I am really confused.)

  • 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-02T14:40:54+00:00Added an answer on June 2, 2026 at 2:40 pm

    By calling the super method, you’re not overriding the behavior of the method, you’re extending it.

    A call to super will perform any logic the class you’re extending has defined for that method. Take into account that it might be important the moment when you call super‘s implementation in your method overriding. For instance:

    public class A { 
        public void save() { 
             // Perform save logic
        }
    }
    
    public class B extends A {
        private Object b;
        @Override
        public void save() { 
            super.save(); // Performs the save logic for A
            save(b); // Perform additional save logic
        }
    }
    

    A call to B.save() will perform the save() logic for both A and B, in this particular order. If you weren’t calling super.save() inside B.save(), A.save() wouldn’t be called. And if you called super.save() after save(b), A.save() would be effectively performed afterwards B.save().

    If you want to override super‘s behavior (that is, fully ignore its implementation and provide it all yourself), you shouldn’t be calling super.

    In the SAXParser example you provide, the implementations of DefaultHandler for those methods are just empty, so that subclasses can override them and provide a behavior for those methods. In the javadoc for this method this is also pointed out.

    public void startElement (String uri, String localName,
        String qName, Attributes attributes) throws SAXException {
        // no op
    }
    

    About the super() default call in code generated by IDEs, as @barsju pointed out in his comment, in each constructor there’s an implicit call to super() (even if you don’t write it in your code), which means, in that context, a call to super‘s default constructor. The IDE just writes it down for you, but it would also get called if you removed it. Also notice that when implementing constructors, super() or any of its variants with arguments (i.e. super(x,y,z)) can only be called at the very beginning of the method.

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

Sidebar

Related Questions

If you have ever had to make you own custom buttons for Android then
I just want to make my own HOME-SCREEN in android. I also want to
I want to make my own simple game UI, and I think I know
I want to make my own Start Menu replacement and I am trying to
I want to rotate my own FrameLayout in 3d in android. Do i have
I want to make my own keyboard. I have the following code When I
I want to make use of the android xml layouts. I have put a
Does every gem have its own rake? Because I was doing android development and
I am using the following code to make a custom checkbox with my own
I want to make my Android app look a little bit sexier but as

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.