Skip to content
Advertisement

Tag: inheritance

Print a value of an extended class object from mother class object

I’ve declared a table that has the mother class type and i’ve filled it with many objects that have the extended classe type, everything looks fine and the table is successfully filled, the problem is when i’m trying to access to the table values i cannot ( in the exemple i’m trying to get the salaire attribut ) MOTHER CLASS

Spring implements to kinds of Repository interface

I’m trying to study Spring more specific Spring Data but i have a question about the use of interface Repository and its derivatives classes and i asking you help for clarify them. For example i see this code example extends CrudRepository but i see the using of extends keyword but no implements. why ? I thought that extends is for

How to show that a Catch block for the Parent-exception will handle subclasses as well

I have met this problem. I have created a class CatHandler, with 3 inner classes (ExceptionAlpha extends Exception, ExceptionBeta extends ExceptionAlpha, ExceptionGammer extends ExceptionBeta). These three exception subclasses are empty; they contain no code. All code should be written in CatHandler. Now the question is to write some code in CatHandler to show that ExceptionBeta and ExceptionGammer will be caught

Inheritance, setters and getters (Game Class Output)

How am I supposed to decrease its armor first and next the health? I want not to print the negative of armor, and I want to print if the armor gets 0, the health should be the next to decrease. For Instance in Testing Class, I use wizard and cast a spell to fireball 3 times to knight. Since knight

NoArgsConstructor and AllArgsConstructor annotation on Child class for parent constructors

Hello to the overflow community, I am struggling on an inheritance problem with Lombok. I’m trying to add both annotation @AllArgsConstructor and @NoArgsConstructor on a child class in order to use the parent lombok constructors but got the error “Duplicate method Child()”. Parent class: Child class: The error message: Duplicate method Child() in type Child Java(67109219) Thanks to the @rentox98

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

Advertisement