Why Does super() Cause Issues in Java Inheritance?

  • Java
  • Thread starter the other guy
  • Start date
  • Tags
    Java
In summary, the conversation discusses the process of importing properties from one file to another in JAVA. The executable file connects to a subclass file, which is a subclass of a parent class. The parent class provides details, while the subclass overrides some of them to create a unique subclass. The speaker is in a rush and is looking for a concrete solution rather than tips. They are encouraged to ask specific questions and not wait until the last minute. The problem was eventually solved, and the speaker will keep these suggestions in mind for future reference.
  • #1
the other guy
19
0
So, I'm new with the JAVA, and I am trying to import the properties of one file, into another. it looks like this-


the executible file will connect to a subclass file (called subclass1), but subclass1 is a subclass to another class file (parentclass)

the parent class will give details, and i want the subclass to override some of them, making ths subclass unique.

im in the 11th hour, id love if someone could for sure give me the answer and not tips since i really can't afford the time!
 
Technology news on Phys.org
  • #2
Even if someone wanted to give you answers rather than just hints I'd say it must involve a great deal of luck if the answers are to useful for you because as far as I can see there are no specific questions to match the answers to.

However, I'm pretty sure that if you cite concrete code you have made and ask specific questions as to why it this or that doesn't work as you expect, you will get answers. And don't be afraid to ask questions early rather than wait until 11th hour where everything has to be rushed.
 
  • #3
thats ok, i figured it out in the nick of time. silly problem with housekeeping turns out ;p
im going to keep those items in mind though.
 

What is the purpose of super() in Java?

The super() keyword in Java is used to call the constructor of the parent class. It allows child classes to access and inherit properties and methods from the parent class.

What is the issue with using super() in Java?

The problem with super() in Java is that it must be the first statement in the constructor of the child class. If it is not, the code will not compile.

Can super() be used in any method other than the constructor?

No, super() can only be used in the constructor of a child class to call the constructor of the parent class.

How can the problem with super() in Java be resolved?

To resolve the issue with super() in Java, the super() keyword must be the first statement in the constructor of the child class. Any other code or logic can be placed after the super() call.

Are there any alternatives to using super() in Java?

Yes, there are alternatives to using super() in Java such as using the keyword "this" to access properties and methods of the parent class, or using the "extends" keyword to inherit from a parent class without calling the super() constructor.

Similar threads

  • Programming and Computer Science
Replies
1
Views
3K
  • Programming and Computer Science
Replies
4
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
2K
Replies
2
Views
2K
  • STEM Academic Advising
Replies
13
Views
2K
  • STEM Academic Advising
Replies
10
Views
5K
  • General Discussion
Replies
2
Views
3K
  • General Discussion
Replies
10
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
20
Views
4K
Back
Top