Posts by Vinicius • 1,925 points
42 posts
-
1
votes1
answer1477
viewsQ: Generate PHP system logs
I need to generate a text document of type .txt containing information on changes made to a system web. This information is about user activities such as registration, registration changes,…
-
1
votes5
answers789
viewsQ: List comprehension with conditional
My goal is to count how many elements of a given list correspond to a condition. To do so, I made the following lines of code: cont = 0 seq = [] max = 10 for x in seq if x == max: cont = cont+1…
-
3
votes1
answer3270
viewsQ: Step by level in binary tree
Description of the problem I need to solve: "A level walk on a tree, first list the root, then all nodes that are at level 1 then all nodes of level 2, etc. Write a procedure to list the nodes of a…
-
7
votes1
answer2359
viewsQ: Difference in the application of Dijkstra and Prim algorithms
What is the basic difference in the field of application of Dijsktra and Prim algorithms? What problems does one solve that the other cannot solve? Having, for example, the following situation: it…
-
0
votes1
answer78
viewsQ: Use of the Big Integer class to build an MD5 hash
I found in another post right here in the OS the following example of code to generate a hash through MD5: String message = "teste1234"; byte[] hash =…
-
1
votes1
answer552
viewsQ: Container and swing design
What are the precise definitions of Container and Component in Swing? Why are these elements important for building the GUI?
-
2
votes1
answer797
viewsQ: Order of class initialization/instantiation
class Bird { { System.out.print("b1 "); } public Bird() { System.out.print("b2 "); } } class Raptor extends Bird { static { System.out.print("r1 "); } public Raptor() { System.out.print("r2 "); } {…
-
1
votes2
answers590
viewsQ: How does creating an Array work?
When using the command new() for the creation of any object we call the constructor of the class of that object and obtain the reference to the instance created. However, what happens when creating…
-
6
votes3
answers246
viewsQ: Deal with exception that guaranteed will not occur
Here is an example of a method to illustrate the context of my doubt: public void comprar(int numeroLoja, int numeracaoProduto, String nomeMarca) throws LojaNaoExisteException,…
-
2
votes1
answer207
viewsQ: Table Hash with quadratic method
I am implementing a hash table with quadratic scanning method. My question is about the position 0 of the vector used for table implementation. Follow the code below: public boolean inserir(Pessoa…
-
7
votes3
answers1081
viewsQ: Sort chained list with O(n*log(n) method)
I need to sort a chained list (own implementation, without using Java API) with a sorting method that has O(n*log(n) complexity. Researching methods that satisfy the condition found the quicksort,…
-
3
votes1
answer353
viewsQ: Aggregation and composition in various relationships
Given a class A, let us say that the relation between this class A and a class B is composition, where A is the class "all" and B is the class "part". Given a third class C, can there be another…
-
1
votes1
answer1990
viewsQ: Priority queue implementation using vector
I am implementing a priority queue through an array, my method for insertion works normally: public boolean inserir(int n){ if(estaCheia()) { return false; } if(estaVazia()) { fila[nItens++] = n;…
-
4
votes1
answer247
viewsQ: Class 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
votes1
answer1360
viewsQ: MVC representation in UML class diagram
I’m building the class diagram of my project and I got a question at a certain point. In the project I create an instance of my Controller class in main and pass the reference (I know that in Java…
-
3
votes2
answers223
viewsQ: Static constants
enum Animals { DOG("woof"), CAT("meow"), FISH("burble"); String sound; Animals(String s) { sound = s; } } class TestEnum { static Animals a; public static void main(String[] args) {…
-
1
votes1
answer521
viewsQ: Check if object is part of class that implements certain interface
I need to create a condition to know if a given object is part of a class that implements a certain interface. How can I do this?
-
2
votes0
answers103
viewsQ: Sort chained list in MVC standard project
In my project I am using my own chain list implementation, that is, I am not using the ready list of the Java API. In addition, my implementation is of a generic list, which has Object objects on…
-
5
votes2
answers993
viewsQ: Operation of variables by reference
I know that variables by reference in java serve to provide a location in memory of a certain object. However, how does this mechanism work? It is equal to the C language, where the reference types…
-
13
votes1
answer755
viewsQ: Difference between casting and Promotion
What is casting? What is Promotion? What is the basic difference between these Java conversion types?
-
1
votes0
answers111
viewsQ: Connection between Controller and other classes in the class diagram
I am modeling a project through the UML class diagram, this project is guided by the MVC standard, so that in a given Controller method I receive information, I instate a new object and insert this…
-
15
votes5
answers1643
viewsQ: Difference between private and final methods
Studying methods and final classes in Deitel’s book "How to program in Java 6 ed." I came across the following proposition: The declared private methods are implicitly final because it is impossible…
-
4
votes1
answer282
viewsQ: Main location in a project with MVC pattern
Within a project guided by the MVC standard where the main() application should be located? Thinking a little I imagined it was the model, because it contains the most "complex" parts of code, but…
-
3
votes1
answer43
viewsQ: Iterator in MVC pattern
I am doing a project and it was asked to build an iterator class. This whole project is being built based on the MVC standard. So what would this Iterator class be and how would I use it? By q I’ve…
-
3
votes2
answers461
viewsQ: Problem removing element from a chained list
I’m implementing a chained list in Java. However, the removing function is causing me some problems, but specifically the removing part in the middle of the list. My list consists only of a field of…
-
3
votes2
answers409
viewsQ: Pass-by Object Reference Wrapper to Method
I have been researching about passing by reference in Java and realized that it is not possible to perform this procedure directly. As only object references and array’s can be passed by reference I…
-
9
votes3
answers8723
viewsQ: Difference between "Attribute" and "Instance Variable"
Reading some books and articles about introduction to Java and OO I realized that these terms are not well defined. Looking deeper I found different definitions in different sources on the subject.…
-
0
votes1
answer70
viewsQ: Date storage of the system
I need to capture the system date and store it in an entire variable, as I will need to compare it to a date that will be informed by the user. I found the function _strdate that stores the date on…
-
6
votes1
answer1150
viewsQ: Recursive analysis of a vector
QUESTION: Write a function recursive that analyzes the elements of a vector and returns one of the following codes: 0 Disordered elements 1 Elements sorted in ascending order 2 Constant elements 3…
-
4
votes1
answer152
viewsQ: Typing a pointer to struct
I was suggested to build a chained list using the following struct knotted: typedef struct node *link; struct node{ int item; link next; }; As I did not understand what the pointer operator means…
-
0
votes2
answers211
viewsQ: Create chained list with realloc()
I need to implement a simply chained list that does not have a next indication, that is, it should function as an array, accessing nearby positions in memory. I’m using the realloc() command to try…
-
3
votes2
answers1697
viewsQ: Remove element from a chained list
I am implementing a chained list of type "with head". It follows struct referring to the list and its creation in main() struct lista{ int info; struct lista *prox; }; typedef struct lista Lista;…
-
2
votes2
answers339
viewsQ: String reading and input buffer
I always used the fgets() function to read keyboard strings, because it (at least I thought so) always clears the input buffer. However, I am finding some errors with the execution of the function…
-
7
votes2
answers330
viewsQ: Dynamic allocation and runtime of functions
When we use any of the dynamic allocation functions in C (malloc, calloc, realloc, etc.), within a function that is called by main, will the memory remain allocated at the end of the execution of…
-
2
votes1
answer260
viewsQ: Union and type conversion
Searching about Unions I found the following information: Unions are usually used for type conversions. For example, we can use a Union to write the binary representation of an integer in a disk…
-
1
votes1
answer629
viewsQ: Open a file using secondary function
I need to create a function that "points" a file pointer to a particular file in computer memory. I was able to do this: #include <stdio.h> void abre(FILE*); void procedimento(); int main () {…
-
7
votes1
answer598
views -
12
votes3
answers366
viewsQ: Variable in main is global?
I read that global variables are those that we declare outside of all functions using #define and this way they could be used by all functions of a program. However, I was informed that the…
-
5
votes3
answers6933
viewsQ: Rotate matrix by 90º
I need to create a C algorithm to rotate a 10x10 matrix by 90 degrees, however I cannot use an auxiliary matrix for this. Simplifying what was asked to try to find some pattern and use it to solve…
-
5
votes4
answers456
viewsQ: Memory allocation for pointers
I’ve been reading and studying on pointers and came across the following quote in a book: "Although it is possible to use them as vectors, pointers do not have their own memory. You can only use…
-
11
votes2
answers1506
viewsQ: What is the difference between assigning and comparing string variables with function or with assignment and comparison operator?
I came across the following questions: What is the difference between expressions strcpy (s, t) e s = t ? What is the difference between expressions if (strcmp (s, t) < 0) e if (s < t) ? I…
-
5
votes1
answer139
views