From my understanding, no objects are instantiated in compilation time. Hence, the error should be classified as a run time error when the instance of the abstract object is created in runtime. Am I correct or will such an error be picked up by the compiler before runtime? Answer The work of compiler basically boils down to accepting your java
Tag: abstract-class
Abstract Classes & Methods In Java
I am working on a Java exercise where a parent class is abstract, and the subclasses override the isSimilar method. This method should take a device parameter. In the Server subclass, this method should compare the Brand, Operating System, and Available Services. In the NetworkDevice subclass, this method should compare the Brand, Number of Ports, and Power Over Ethernet. The
Java: Abstract class with builder pattern
I hope this isn’t a duplicate; I know there are some similarly named questions but none of them seemed to solve my problem. I have multiple classes that are exactly the same – apart from one specific method. So I decided to create one abstract parent class, let’s call it A. A runs all the code and has one method
abstractor method with object return type in java
I’m new at oop ,I want to pass object parameter of an abstract method but it gives me error, can anyone explain it to me and help me fix the error . Thanks for your help. Answer You cannot change the abstract method signature. You have created an entirely new method unrelated to the method you wanted to override. Use
Deleting all occurrences in a circular linked list. (java)
I want to implement a method that deletes all occurences of a certain value given as argument. I created 2 temporary elements and referenced them to the head and I will be browsing the list using them. I was able to write a whole code but I’m not getting any result, I don’t know where the problem is, neither I
How to properly unwrap an optional in Java?
I am learning the basics of Java and I am exploring Optionals and abstract classes so I came across the following issue, I have this code I was expecting to see the prints on the console “It is a Dog” followed by 2 “It is not a Dog” Since I’m using the method .isPresent() on optionals, But I got 1
Abstract class with Gson serialization/deserialization
I am expecting to get from a json a LinkedList<Request>. The pojos look like this: The serialization works fine, it generates the json, but it crashes at deserialization (maybe it’s the abstract class or/and that I am expecting a LinkedList and/or the lombok annotations)? I tryed writting a gson deserializer (quite a standard one found googling), but it doesn’t do
abstraction can be done without inheritance? java
Is abstraction possible without inheritance? This is my code Please note above, how i: did not extend the class “what” from abstract class “whatever” and yet the code runs perfectly with no errors Did not declare class “what” as abstract (since it’s not declaring the other two methods disp2() and disp3()) I am very confused. Please help. Answer There is
Java override abstract generic method
I have the following code However I don’t know how to do this, as I cannot override doEventStuff with something specific. Does anyone know how to do this? Answer It’s not really clear what you’re trying to do, but perhaps you just need to make Event itself generic: