Questions tagged [abstract]

abstract is a keyword shared by a multitude of object-oriented programming languages. Methods and classes can be marked abstract to indicate that they do not contain the full implementation of application logic and have to be extended. Abstract classes can not be instantiated and serve the purpose of providing a uniform interface for their subclasses, as well as the implementation of common methods that don't have to be reimplemented for each subclass.

abstract is a keyword shared by a multitude of object-oriented programming languages.

Methods and classes can be marked abstract to indicate that they do not contain the full implementation of application logic. Abstract classes can not be instantiated and serve the purpose of providing a uniform interface for their subclasses, as well as the implementation of common methods that don't have to be reimplemented for each subclass.

The exact meaning of abstract depends on the programming languages in question, some of them being: Java, C#, php, C++, Delphi Pascal. Similar logic can also be implemented using different keywords in other languages ( for example, Oracle PL/SQL allows to create abstract classes and methods by declaring them NOT FINAL)

The power of abstract methods and classes is widely used by design patterns.

2521 questions
0
votes
1 answer

How to write Builder Pattern for class that extends abstract class in Java?

I have the "Client" class that extends abstract class "User": public abstract class User { private Long id; private String firstName; private String lastName; private String email; //getters and setters } public class Client…
G T
  • 57
  • 1
  • 6
0
votes
1 answer

What should I do abs in objectfunction

I want to find an expression with an absolute value as an objective function in gurobi. Specifically, it is an expression such as ∑_j ∈ J | ∑_i ∈ P x_ij-d_i *t_i |. The variable is x_ij, and the others are constants. I tried and errored this formula…
0
votes
1 answer

How to limit instantiation of class and methods in it -Java

@AllArgsConstructor(onConstructor = @__({ @Inject })) public class TransactionManager { private final TransactionHelper tnxHelper; public void createTransactions(List
details) { tnxHelper.createTransactions(details); …
0
votes
1 answer

How to invoke an abstract method from main method using array objects

In the below code , I'm trying to calculate the GPA of the undergraduate given the grade point and credit values. But how Can I invoke the calGPA method in the main method ? CalGPA should be an abstract method so i cannot make it static because I…
Allen Hay
  • 81
  • 1
  • 7
0
votes
2 answers

Is it possible to override abstract beans in Spring?

I'm trying to override this bean which is provided by standard Hybris (OOTB) framework. I would love to override it so it uses my own custom class. Is this possible?
0
votes
1 answer

Implement generic abstract method with properties not present in abstract class

I have the following setup: abstract class Vehicle with the following simplified structure: public abstract class Vehicle { public string Brand { get; set; } public string Model { get; set; } public string GetBasicInfo(Vehicle v) { …
Stefan
  • 59
  • 8
0
votes
1 answer

How to pass user input values to private variables in abstract classes (JAVA)

I'm trying a past paper question for Object Oriented Programming. I need to pass user input values to private variables in an abstract class. But since abstract classes cant be instantiated I cannot pass the user input for the variables in the…
Allen Hay
  • 81
  • 1
  • 7
0
votes
0 answers

How can I abstract try-catch block for using it without repeating code?

I have many hours struggling with this problem. I have the following line of code: Mockito.doReturn(new ErrorResponse()).when(mockobjectMapper).readValue("Test", ErrorResponse.class); The method "readValue" spits an error: Unhandled exceptions:…
Evoldev
  • 35
  • 5
0
votes
1 answer

Unity Abstract class with parameter

I have not been able to figure out the purpose of the "new()" word in this code. I appreciate any insight and help understanding it. What is the meaning/functionality of "new()" in this piece of code? public abstract class…
luis
  • 107
  • 1
  • 8
0
votes
0 answers

Correct way to use URL Patterns, Views & Templates when using the Django Abstract base classes for my models

Are there better approaches to this problem? This model structure is what I am after for my database. So I am feeling like I am breaking the DRY rule with my learning project. Using Django 3.2.9 & Python 3.9.6 I have looked around the internet on…
Rishu
  • 1
  • 2
0
votes
4 answers

why can I not use methods of my extended class correctly?

I am working on a project that uses abstract classes. I have mad the class Item, and then I made a "Snickers" and a "Mars" class that both extend the Item class. I am using it in stacks, and after I fill these stacks, I am trying to print out the…
gone
  • 13
  • 5
0
votes
2 answers

Abstract class doesnt return anything

This is my code: class Program { abstract class Shape { public abstract double GetArea(); } class Rectangle : Shape { double length = 100.57; double width = 100.14; public override double…
user16859238
0
votes
2 answers

Abstract Api Validation for Mobile number

Hello everyone I am trying to validate the mobile number using abstract api validation but I am stuck to check which number is valid and which number is not valid for this I write a code. $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,…
0
votes
1 answer

About Java Bean

Possible Duplicate: What is a Java Bean exactly? This is a simple question about Java Bean, there is some restriction in the type of classe? For example, a bean can be a abstract class ? Thanks
Édipo Féderle
  • 4,169
  • 5
  • 31
  • 35
0
votes
1 answer

what's the whole point of @abstractmethod in here ? cause it works even if it's not there

In this example which I get from https://www.askpython.com/python/oops/abstraction-in-python I try to understand what's the uses of abstraction but I get a little bit confused #if i dont import this it will run yet so what's the point from abc…
EBG
  • 1
  • 1