Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Filter by
Sorted by
Tagged with
Advice
0 votes
9 replies
120 views

Why the inherited method output parent's data?

Explain please why the output is "Base" ? Isn't getClassName method inherited? class Base {     public String className = "Base";     public String getClassName() {         ...
J.J. Beam's user avatar
  • 3,171
3 votes
1 answer
185 views

“The type initializer threw an exception” even though static fields are initialized [duplicate]

I'm getting a TypeInitializationException when running this C# code. It happens when a constructor tries to add an instance to a static list that should already be initialized. You can run it here: ...
Özgür Utku's user avatar
0 votes
1 answer
128 views

C# .NET extension without extension method [closed]

I have a base class and multiple derived classes: public class Camera { } public class CameraManufacturerA : Camera { } public class CameraManufacturerB : Camera { } public class ...
Moj's user avatar
  • 47
Best practices
1 vote
6 replies
217 views

Base class and derived classes in Qt

I'm building a Qt wrapper for RtMidi. As starting point I created two separate classes QMidiOut and QMidiIn that wrap RtMidiOut and RtMidiIn. I don't want to duplicate code for the common methods (e.g....
NoobNoob's user avatar
  • 104
-2 votes
0 answers
56 views

On calling inherited method from parent class by object of child class why instance variable of parent class is printed [duplicate]

class parent{ private String x = "Parent"; public void printmsg() { System.out.println("value is "+ this.x); } } public class child extends parent{ ...
Bhupesh's user avatar