All Questions
Tagged with inheritance java
8,694
questions
-1
votes
0
answers
20
views
Need to extract a method to use in equals implementation with Hibernate DTO's
I am updating a Java project and had to add an equals() implementation 3 java DTO files (call them Child1, Child2 and Child3) which all extend the DTO Parent class. IntelliJ generated the following ...
-1
votes
0
answers
32
views
Does a socket instantiated in a parent class belong to its child class?
I'm making a messaging service in java where I'm using sockets and object input/output streams. I wanted to make this as object oriented as I can (to learn OOP) so for the client side I'm making an ...
1
vote
1
answer
42
views
Inherit override-equivalent as different methods
Several methods from interface, super class or new method are override equivalent. I need to make different realization for each. Example:
public interface A {
int f();
}
public interface B {
...
3
votes
1
answer
49
views
Multiple constructors annotated with Lombok @Builder cause a problem?
This is my first question, so please feel free to correct anything that I missed writing this question:)
I am having trouble with using the @Bulider with my DTO objects.
I have an abstract class "...
-1
votes
0
answers
32
views
Polymorphism in Java Spring [closed]
I develop an application in Java Spring. I have an abstract superclass called AbstractPuzzle and I have its children called Wordle and Riddle(I have JOINED type of inheritance).
I get an ...
2
votes
0
answers
66
views
Base class not recoginsed while using wild card generic
Why is the below not working?
A b1 = new B();
Function<? super B, ? extends A> function = x -> new B();
A apply = function.apply(b1);
It gives an error "Required type capture of ? ...
-2
votes
2
answers
67
views
How do I create a member that can accept 2 very similar interfaces?
I currently have two classes that do exactly the same but have differences of a single member.
interface interfaceA {
VariationA getVariation();
}
interface interfaceB {
VariationB ...
-1
votes
1
answer
28
views
Why does the custom ArrayAdapter constructor in this example not match the superclass constructor exactly?
I was following a tutorial on creating a custom ArrayAdapter for a ListView in Android. Here is the custom adapter class from the tutorial:
public class NumbersViewAdapter extends ArrayAdapter<...
-1
votes
1
answer
41
views
Java Protected Field Access Issue in Subclass
What is the difference between public, protected, package-private and private in Java?
The question's answer cannot answer my question. It's not a duplicate question. I totally know the diagram of ...
0
votes
2
answers
48
views
How to upgrade Java class to extension class?
I have a simple problem. I have a large class:
public class Base {
public Field1Data field1;
public Field2Data field2;
public Field3Data field3;
// many more fields later...
public ...
0
votes
0
answers
16
views
Efficient design solution for handling dynamic marking schemes with multiple levels and subjects
We're developing a grading system for a school with multiple levels (e.g., elementary, middle school, high school) and various subjects within each level (n subjects < 200). The challenge is that:
...
0
votes
2
answers
60
views
Initializing properties of derived classes in Kotlin
I want to know why exactly my code returns "nullnullnull" instead of expected answer and why does it work correctly when method is used.
Consider the following code:
open class Base(
...
-1
votes
3
answers
125
views
Are all abstract classes parent classes? [closed]
I started learning Java few months ago. I am wondering if all abstract classes are parent classes. An abstract method in an abstract class won’t have a body. So the abstract method it must be ...
1
vote
2
answers
65
views
Is it possible to override a Point2D object from a superclass to a Point2D.Float?
I have defined a class called Entity with a Point2D object in it called pos. The class is a superclass and it's not specified if pos should be a Point2D.Float or a Point2D.Double, that's left for the ...
0
votes
1
answer
52
views
Why JPA is adding fields of subclass when dealing with superclass? How to prevent that?
I want to use a SQL function to get length of a saved blob.
I use jpa, an enity and a repository for that.
My implementation looks more or less like this:
public interface UploadRepository extends ...