Most voted "classes" questions
In object orientation, a class is a structure that abstracts a set of objects with similar characteristics. A class defines the behavior of its objects through methods and possible states of these objects through attributes. In other words, a class describes the services provided by its objects and what information they can store.
Learn more…715 questions
Sort by count of
-
6
votes2
answers141
views -
6
votes1
answer2344
viewsMake a generic vector in Java
How to create a dynamic vector in Java with generic programming? This vector must have initial size 4 and be increased in size as new elements need to be inserted. The class must have: Constructor.…
-
6
votes1
answer480
viewsIn a C#console program, where is the main class set?
I’m doing my first console program in C#, just to do some tests. I have two classes: HelloConsole.MainClass and HelloConsole.Calc. I have the following code: using System; // Aprendendo o alias de…
-
6
votes2
answers7914
viewsWhat is the difference between Java Keywords extends and Java Implements?
I would like to know when they should be used and how we can distinguish them. I know that basically Implements, means that this class implements a class or an interface. E extends can access the…
-
6
votes3
answers709
views -
6
votes2
answers614
viewsInterface and inheritance for the Java connection class
Considering the object orientation, would the use of inheritance and interface in this way be correct? But in this way, any request for connection to the database will need a new object. Would have…
-
6
votes1
answer2127
viewsHow to clone objects in Python?
In some languages, besides being able to instantiate a class to construct a given object, we can also clone an existing instance, if we want an object with the same characteristics of the current…
-
6
votes1
answer298
viewsPerformance differences between structs and classes
I know the difference between structs and classes is that structs has its public members by default, and that structs belong to C (but nothing prevents use in C++). In practice when creating an…
-
6
votes3
answers844
viewsSorting of object vectors
I am making an application that sorts an object vector. These objects are Cartesian points, defined in the following class: class CartesianPoint { private: int x; // Coordinate X of a pin or a wire…
-
6
votes3
answers1428
viewsHow to define the comparison of equality between two objects present in an Arraylist?
How can I define the equality comparison behavior between two objects whose class is defined by me that are stored in an Arraylist object? Java nomecor. public class NomeCor { private String nome;…
-
5
votes2
answers756
viewsHow to use arrays in Java?
It’s a very beginner question (I’m new to Java, I came from C++). I have to do a program that takes 4 grades from 10 students, but when I go to work with the "pointers" (arrays), my program returns…
-
5
votes1
answer3020
viewsWhat is the best way to create methods accessible to any Ctivity?
Hello. When I need to create a method for an Activity I simply write it in my Activity code. For example: package com.pcriot.maxsoft.testapplication; import android.os.Bundle; import…
-
5
votes1
answer162
viewsHow to get the name of all user classes?
The function get_declared_classes magpie ALL the classes defined in PHP, both from the internal PHP library and from the user. I wanted a role for classes like: get_defined_functions, that separates…
-
5
votes4
answers374
views -
5
votes1
answer608
viewsDifferentiate interface "instance" class instance
Got some way of differentiating v1 of v2 in the code below, by reflection or other method? var v1 = new MinhaClasse(); IMinhaClasse v2 = new MinhaClasse(); I want to run a method only if a variável…
-
5
votes2
answers180
viewsUse Static Closures or Closures in PHP?
As of PHP 5.4, the Closures (Or funções anônimas), when declared within the context of a class method (other than static methods), automatically inherit to "within" the $this as a reference to the…
-
5
votes2
answers2743
viewsHow do I set a private property in Python? And is there a protected property?
I come from PHP. In it, when we want to define a property of a class as private we add the keyword private in his statement. Example: class StackOverflow extends StackExchange { private $language =…
-
5
votes2
answers305
viewsHow to model plots when you don’t know how many there are?
Usually, when it comes to payments in instalments, comes the idea of 12 installments. Then you soon create a table with 12 fields, one for each portion. But I am faced with the situation that the…
-
5
votes3
answers2556
viewsHow to know how many objects were instantiated?
In a Java application, how do I know how many objects in a class were instantiated? This doubt came to me by reading the article mentioned in the link below. It follows the excerpt that led me to…
-
5
votes1
answer150
viewsWhat is the "class" restriction on a generic type?
In the line below: public class Tree<TItem> where TItem : IComparable<TItem> This line I’m creating the definition of type TItem where TItem implements the interface IComparable, i.e., I…
-
5
votes1
answer930
viewsWhat is the difference between Classes and Interfaces?
What’s the difference between classes and interfaces? I’ve read that apparently the difference in interfaces is because they are 100% public, but I have no idea. Could someone explain the difference…
-
5
votes1
answer153
viewsWhy use __debugInfo()?
I saw that PHP 5.6 has now created the new magic method called __debugInfo. This method aims to return a array, which will be printed in the var_dump. That one array returned obviously must offer…
-
5
votes2
answers124
viewsPython: How to store the documentation(help) of a class in a String?
I’m doing a Python class explorer. I can store class methods and attributes with dir(obj) and place them in a Treeview. I would like to display the references of this when clicked. For this I would…
-
5
votes1
answer346
viewsWhen should I instantiate a class?
I’m having second thoughts about the best time to call for instantiate a classe. Should I do it at the beginning, before the builder, at the constructor or at the time when we will make use of some…
-
5
votes3
answers1022
viewsYou’re a builder, right?
I’d like to understand why this class has two builders and why one of them has everything in it this and not separated as in the other. This changes something? Normal builder: public…
-
5
votes2
answers4177
viewsHow does hierarchy elements work in css?
I would like to know how the hierarchy works in css, I explain: Let’s say in mine style.css i set to h1, h2, h3, h4, etc. by default font-size: 12px;, hitherto beauty... Now, if for example I insert…
-
5
votes1
answer1139
viewsHashmap manipulation between classes (Interpretation and Application)
is my first question, sorry for the length, I am in doubt in the following exercise: Create a Pizza class that has the added method Cooking() that receives a String with the ingredient to be added.…
-
5
votes2
answers410
viewsPrivate class in Javascript
I’m looking for a way to make both attributes and methods invisible so they’re not accessible from outside the class. But I also wanted to use the modern approach to do this (class Nomeclass{}).…
-
5
votes2
answers661
viewsHow to transform the class of a "factor" column into "date" within a data.frame?
I have a base extracted in csv (dados_base), with the period from Dec/2017 to Jan/2019, which has three columns: USUARIO, DT_PAGTO and VL_PED_PG, where the first field represents users with the…
-
5
votes1
answer109
viewsDoubt about generic types in Typescript
I am currently studying Typeorm, and wanted to create a generic controller, as it will always be the same CRUD operations. I know I can solve with native Typeorm solutions, such as getRepository(),…
-
4
votes2
answers1232
viewsDifferences when instantiating a class
Using the PHP when instantiating an object I do it as follows: $obj = NEW my_class_exemplo; but always the netbeans auto complete gives me the option to put parentheses like this: $obj = NEW…
-
4
votes2
answers144
viewsHow to make a constructor equal to Qobject?
When a new question arises from an old question, I want to know how to create a class equal to QObject. Basically, I want to know: How to make a copy constructor that does not accept "assignment…
-
4
votes2
answers366
viewsWhat happens to class name resolution in php 5.5?
PHP 5.5 implemented a new feature, which consists of getting the class name through the keyword class: Example: namespace testando; class Teste{} echo Teste::class; // testando\Teste; This works…
-
4
votes3
answers3392
viewsHow to use static and global variables in PHP?
I need the value of a variable in several functions to increment and decrement the value of the variable. I have tried using static variable started with null value, but even changing its value, it…
-
4
votes3
answers10588
viewsGlobal variable in all functions of the class
Usually when I want to pull a variable that is out of class, I use global $variavel, but wanted this variable to be accessible in all functions of the class, not to be needing to "pull" in all…
-
4
votes1
answer84
viewsJava class for performance analysis of my project
I’m looking for a Java class or bundle to help me analyze the performance of my app. I need information such as: processing time, memory consumption, processor usage ... and so on. I know there are…
-
4
votes2
answers2699
viewsRevert a string and add method to native objects in Python
In Python, we have the method reversewithin the List. It reverses the order of a list. Example: [1, 2, 3].reverse() // [3, 2, 1] However this method is not present in a string. example (Python):…
-
4
votes3
answers210
viewsWhat’s the difference between var $var and public $var?
I have a class: class anyClass{ public $var1; var $var2; } The difference between $var1 and $var2?
-
4
votes1
answer118
viewsClass creation that returns a String
Hello guys I’m beginner in Java Android and I’m having a little problem, I’m trying to create a class that returns a String. I create the file .java and paste my code but gives the following error…
-
4
votes1
answer837
viewsHow to organize CRUD methods for each table?
I would like to know how to organize the CRUD (create, read, update, delete) methods of each class in Java. An example, to better understand: Suppose we have the classes Funcionario, Cliente and…
-
4
votes2
answers395
viewsHow to verify if a constant exists in the class or in a namespace?
In PHP, to check if a constant exists we use the function defined. As below, for the two cases of constant declaration: const MY_TEST_1 = 'my test 1'; define('MY_TEST_2', 'my test 2');…
-
4
votes1
answer672
viewsDelete information from a vector that is in another C++ class
Hello, I have a question regarding classes in C++, I hope someone can help me. Thanks in advance! I am developing a work for college where I need to register students, disciplines and grades and at…
-
4
votes2
answers1263
viewsHow to search by class (instead of id) in Javascript/jQuery
I’m using a plugin for popular city/state, but I wanted to use in more than one select, so I wanted to use per class instead of ID, but what I tried so far didn’t work. I tried to follow this famous…
-
4
votes1
answer247
viewsClass aggregation and attribute ratio
Aggregation only occurs when a class A, which aggregates a class B, has an attribute of the type B? There can be aggregation without necessarily having an attribute of the type of the other? For…
-
4
votes4
answers7150
viewsIn inheritance with private attributes, does not the daughter class take its attributes from the mother class?
The devmedia article says the modifier private does not give access to its attributes in its child classes. It has a table with modifiers. In inheritance with private attributes, the daughter class…
-
4
votes2
answers447
viewsHow to adapt / create a method that receives an anonymous class in C#
I have a method in which one of the parameters is an object of an abstract class - Objectmapper - whose purpose is to convert an object of one class into another of another class. Below, the method…
-
4
votes1
answer1370
viewsDoubt in class diagram
I am developing my class diagram of a project and got the following question: How do I indicate that only ADM can register a contributor? Do I have to put that in the Class Diagram right now? Thank…
-
4
votes1
answer61
viewsPartial for separation of events and methods
I saw in a system a separation of methods in a partial and the events in another in UserControl and Window as the example below: "Pessoa.xaml.cs" public partial class Pessoa: UserControl {…
-
4
votes4
answers4957
viewsCall static class method by static variable
In the PHP documentation, found that code in relation to the target resolution operator :: <?php class OutraClasse extends MinhaClasse { public static $meu_estatico = 'variável estática'; public…
-
4
votes3
answers670
viewsHow to sort sql queries in the RUBY on Rails model?
I have the following method an ROR application. query_student = "SELECT name, registration, room FROM students WHERE registration = "+ params[:registration]+" AND password = "+params[:password]…