Win a copy of Microservices Testing (Live Project) this week in the Spring forum!

Eleanor Leong

Greenhorn
+ Follow
since Mar 24, 2006
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
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Eleanor Leong

We uses entrust java tookit to validate signatures and sign messages.
Recently, we notice the signing function is still working while the signing key expired.
I wonder if anyone experience such issue and know how to fix it.
10 years ago
Thanks very much for your information

Eleanor
Hi,
When a class implements Interface Comparator<T>, it needs to overide all abstract methods of Comparator<T> which are int compare(T o1, T o2) and boolean equals(Object obj)(indicates whether some other object is "equal to" this Comparator).

I am confused now. Then a class will have two equals(). But it doesn't seems to be the case. It seems only int compare(T o1, T o2) needs to be overriden.

Please explain.

Eleanor
Is the following statement true :

Final and private methods are never inherited into subclass when extended.
On the other hand abstract and static methods are inherited.





How do we know something is inherited, no access or just hidden ?

Thanks,
Eleanor
Thanks very much. I understand a lot better now.
The following code is inside a method. What does TThread94.class means
in the code. Is it an Object or a Class?
I think it is trying to synchronized against the TThread94 Class and
using it to notifyAll()?
It is a compile error if I just used TThread.notifyAll(), complaining
non-static method notifyAll() cannot be referenced from a static context.

Hi,
I think only C is correct.
Since no matter which messenger, Wallace or Gormit, 1 has to come before 2.
Option A Gromit-2 is missing
Option B Gromit-2 is before Gromit-1
Option D, Wallace-1 and Wallace-2 are missing
Opriont E Gromit-2 is before Gromit-1

What do you think?
Hi,
If you did not overide the equals() and the hashCode(). the default
equals() and the hashCode() of Class Object is used.
Since you are using d reference which points to the Dog Object which you stored as a key in the Map. the reference d and the key you stored in the Map are pointing to the same Dog object, i.e.
Map key -----> Dog Object
d ---------------|

The hashCode() on d reference will return the address of the Dog Object which is the same as the key in Map. Since they are pointing to the same Dog Object, they are equal according to the equals() of Object.

Hope this is clear enough.
Thanks very much for your help.
Would you please help me to make this work. I modified one of the
K&B exam question as follows:

code:
import java.util.*;
class BackLister {
public static <T> List<? super T> backwards(List<T> input)
{
List<T> output = new LinkedList<T>();
for (T t : input)
output.add(0, t);
return output;
}
}
public class TGeneric96 {
public static void main(String[] args) {
BackLister bl = new BackLister();
List<Integer> ln = new ArrayList();
ln.add (1);
ln.add(2);
ln.add(3);
List<Number> lo = bl.backwards (ln);
System.out.println (lo);
}
}

At Line 19, there is compile error as follows:
TGeneric96.java:19: incompatible types
found : java.util.List<capture of ? super java.lang.Integer>
required: java.util.List<java.lang.Number>
List<Number> lo = bl.backwards (ln);
^

/code
Thanks Pawan.
Its a very good answer.
I understand now.
Hi,
When I changed
List<Integer> list = new ArrayList<Integer>();
to
List list = new ArrayList();

It runs without ClassCastException and prints 3, str.

I am confused also. Looks like the generic declaration List<Integer> causes the exception. But in fact the information of generic type should be erased after compilation.

Why the exception error!!!
The line : InnerTest inner = outer . new InnerTest ( ) ;
creats a instance of InnerTest called inner.

To create the parent class OuterTest , the no arg constructor OuterTest() is called by the super() call inserted by Compiler in the constructor of InnerTest.

In OuterTest() contructor id is assigned to " Default ".


Eleanor
Compiler gives error
cannot assign a value to final variable this
this = new ThisUsage();

Looks like variable 'this' is final and explains why option c is invalid.

Eleanor
d. this.i = 4 won't work since this.i refers to the instance varialble of class ThisUsage. There is no 'i' defined.

Would somebody help to explain why option c. this = new ThisUsage();
is wrong.

Eleanor