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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:43:34+00:00 2026-06-14T13:43:34+00:00

I’m new to JAVA and OOP in general. In this very simple code, why

  • 0

I’m new to JAVA and OOP in general. In this very simple code, why I have to call the onCreate method from the superclass? isn’t it inherited from the superclass? I know that a constructor method is not inherited to the child class and if you want to call the constructor you must invoke the superclass. Is super.onCreate a constructor call? Doesn’t the constructor name must be the same with the class name ?
I know this is a silly question and thank you for your responses.

import android.app.Activity;

public class MainActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
}
  • 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-14T13:43:35+00:00Added an answer on June 14, 2026 at 1:43 pm

    why I have to call the onCreate method from the superclass? isn’t it inherited from the superclass?

    The implementation is inherited, but you’re overriding it. You need to indicate that you don’t just want to replace the original behaviour – you want to execute that behaviour from the superclass and then extra code.

    This isn’t a constructor call – unless you explicitly call the superclass implementation, its code simply won’t be executed. Also unlike constructors, the superclass implementation call doesn’t have to be the first statement of a method. You can call the superclass implementation wherever you like, even multiple times.

    Here’s a short but complete example program demonstrating the difference between calling a super method and not:

    class Super {
        void method1() {
            System.out.println("Super.method1");
        }
    
        void method2() {
            System.out.println("Super.method2");
        }
    }
    
    class Sub extends Super {
        @Override void method1() {
            // No explicit super call
            System.out.println("Sub.method1");
        }
    
        @Override void method2() {
            super.method2();
            System.out.println("Sub.method2");
        }
    }
    
    public class Test {
        public static void main (String[] args) {
            Super x = new Sub();
            x.method1(); // Prints just Sub.method1
            x.method2(); // Prints Super.method2 and Sub.method2
        }    
    }
    

    (It would be entirely feasible for Sub.method1 to call super.method2() by the way. You can call a superclass implementation of any method from the subclass.)

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms
I have a text area in my form which accepts all possible characters from
Does anyone know how can I replace this 2 symbol below from the string

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.