Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!

Mihalydeak Szilard

Greenhorn
+ Follow
since Jan 24, 2002
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
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 Mihalydeak Szilard

and if anyone has a better name than 'DBWithSchema' or my existing 'DBPlus' I want to hear it



How about DB2 ?
Hi Everyone,

This topic has been discussed here earlier too, but now it's my turn to decide what to do about it. Please give your opinion and comments !

My SCJD assignment states:


"Your data access class must be called "Data.java", must be in a package called "suncertify.db", and must implement the following interface: DB"



As always, the provided interface is missing something, which now is support to handle metadata. The only plausible solution I see is to extend interface DB, and use that extended interface throughout the application.



Is this indirect implementation going to be against the requirements ? Sure I could write , but that doesn't make much sense other than meeting a (hidden) requirement to implement DB directly.

br. Szilard,

[Andrew: wrapped text]
[ August 23, 2004: Message edited by: Andrew Monkhouse ]
Jose,
That's right ! The point is to decide whether the compiler considers the overridings approvable...
...what in fact for us, human beings, means that invoking a method it is not ambiguous which one of two methods would be called.
regs.
Szilard,
Tina,
Adding the methods one-by-one to the code, ok, but it does not change anything, the essence of the problem is the same: two ambiguous methods, that is, from the caller's point of view the two methods' declarations are the same.
The caller at the moment of invocation knows nothing about the income, the return value or the thrown exception. If simply calling methodOne(10, 100), how would you choose the right method from:
1.
int methodOne( int a, long b ) throws IOException
and
int methodOne( int c, long d ) throws ArithmeticException
or 2.
int methodOne( int a, long b ) throws IOException
and
int methodOne( int c, long d ) throws FileNotFoundException
If I correctly remember, for ex. in C++ this problem was sorted out by the compiler giving "ambiguous methods", or smth similar.
The 3rd error is clear as well, you cannot override a method by just changing return types.
More wiser people said the same thing like this:
----------
4.4 Overload Resolution
Overloaded methods have the same name as an existing method, but differ in the number and/or the types of arguments. Overload resolution involves determining which overloaded method to invoke. The return type is not considered when resolving overloaded methods. Methods may be overloaded within the same class. The order of method declaration within a class is not significant.
Methods may be overloaded by varying both the number and the type of arguments. The compiler determines which matching method has the lowest type conversion cost. Only methods with the same name and number of arguments are considered for matching. The cost of matching a method is the maximum cost of converting any one of its arguments. There are two types of arguments to consider:, object types and base types.
The cost of converting among object types is the number of links in the class tree between the actual parameter's class and the prototype parameter's class. Only widening conversions are considered. (See Casting Between Class Types for more information on object conversion.) No conversion is necessary for argument types that match exactly, making their cost 0.
----------
Szilard,
Hei,
Keep it simple ! As you know a set of methods are valid only if at invokation time you can select one and only one method based on the arguments you pass.
Try compiling, you'll get:
javac Sub.java
Sub.java:10: methodOne(int,long) is already defined in Sub
int methodOne( int c, long d ) throws ArithmeticException { return 1; }
^
Sub.java:11: methodOne(int,long) is already defined in Sub
int methodOne( int c, long d ) throws FileNotFoundException { return 1;}
^
Sub.java:9: methodOne(int,long) in Sub cannot override methodOne(int,long) in Super; attempting to use incompatible return type
found : long
required: int
long methodOne( int c, long d ) { return 1L; }
^
3 errors
regs. Szilard,
Hi WLS6 gurus !
I met a few WLS6 certification questions I'm not sure of, maybe you can help me with the correct answers:
1. Two stateful session beans are identical if which of the following is true?
a. ����Their data attributes are equal
��b. Their session contexts are equal
2. How can you add managed servers to a domain?
a. Only through the console
b. Through the console and from the command-line
Also I welcome concrete QAs which could be tricky. And thanks to all.
BR Szilard,
18 years ago