Claud Mann

Ranch Hand
+ Follow
since Apr 14, 2020
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
2
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Claud Mann

Junilu Lacar wrote:
You can't override a static method that you define in an interface. Also, any non-static and non-default methods defined in an interface are implicitly public and abstract.



Thank you very much
3 years ago

Junilu Lacar wrote:Unchecked exceptions like IllegalArgumentException are normally not caught in a try-catch block. Unchecked exceptions (RuntimeException and its subclasses) are normally a sign of buggy code so these should be allowed to propagate and be detected during program testing.



Thanks
3 years ago
Thank you everyone.
3 years ago

Junilu Lacar wrote:..
Like I said, there's no "rule" that says you have to store all values passed to a constructor in an instance variable. Using it to configure the class and then throw it away is also a perfectly fine and common approach. If there was a rule of thumb, I'd say it would be that any argument you pass to a constructor has to make sense logically and semantically.



okay! So I can use the fields and the objects of other classes in the constructor of my new class, right?
3 years ago
Good evening everyone,

I have a question for you.

If I have to record a fixed number of integers, is there any reasonable thought which would suggest to use an ArrayList instead of an Array?
3 years ago
Good evening everyone,

I have a question for you. I noticed that inside any interface I cannot create a static and abstract method.
If I want to create a static method (that a class can inherit through the implementation of the interface), should I always write a body and then apply overridding inside the class which inherit the method?
3 years ago
Good evening everyone,

What should I do if I want to create a class that doesn't allow the creation and use of objects?

I thought about an option, please tell me if it is correct and if it is the best one.

I would declare the constructor of the class as a private method with an empty body.

What do you think about it?
3 years ago
Good evening everyone,

Let's consider a method that throw an Illegal Argument Exception if a parameter is not a regular one.

Example:


Question:


If I use this method in a "main" to test the method, I should always use a try-catch form?

Would it be an error, if inside a main I write:


Would it be more correct to write:



?

3 years ago

Junilu Lacar wrote:Please clarify what you mean by "doesn't belong." In your example, do you mean to say that the size parameter doesn't belong to the FibonacciFinder class? How so?



I edited the post.

Exactly. "int size" doesn't belong to the class "FibonacciFinder", however it appears in the constructors' input.
Is it correct? Is it possible to do that?
3 years ago
Good morning everyone,

Let's consider a class and its own constructor:



Is it correct to use an attribute or an object (in this case "int size" ), that doesn't belong to the class, in the constructor of the class (in this case, the class FibonacciFinder) ?
3 years ago
Good evening everyone, I have a question for you:

Let's consider a class Y and a subclass of Y named X.



My question is:
in the subclass X, I can use "var" and "super.var" as two distinct and completely separated attributes, a.k.a. which are not linked?
3 years ago

Junilu Lacar wrote:



In this case X is the super class and Y is the sub-class.
An object whose declared type is Y is also an object who can fit wherever an X object is expected, because of substitubality, right?
This is the reason why casting is not necessary.
Viceversa, an object whose declared type is X need a cast because it is not guaranteed that it will fit wherever an object of Y type is expected, right?
3 years ago

Campbell Ritchie wrote:

Claud Mann wrote:. . , I edited the post. . . .

Kindly don't make that sort of change; I have reverted it. Yo managed to introduce a new error into that post by editing it.other



Ok no problem
3 years ago

Junilu Lacar wrote:
It is still X. Casting does not change the type of a reference variable, it allows you to assign that reference to another reference.



I think this sentence has definitely clarified my doubts about my Upcasting.
3 years ago