Win a copy of Murach's MySQL this week in the JDBC and Relational Databases forum!

Rekha Rao

+ Follow
since Jan 23, 2001
Merit badge: grant badges
For More
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Rekha Rao

In assignment rules for relationships (pg 154 of ejb spec)..

A and B are in one-to-one bidirectional relation..

a1 <--> b1
a2 <--> b2


a1.setB(a2.getB()) will result in

'a2.getB() == null'.

Suppose we just have:

a1.setB(b2) (that is, not accessing b2 through a2), will the container still be aware that b2 is involved with a2 and yield the same result ?
Can a statless session bean acess EJBObject in ejbCreate method ? The EJB specification lists getEJBObject and getEJBLocalObject under operations allowed in ejbCreate method.

I am under the impression that EJBOjbect is created when the client invokes create method on home. For a statless session bean however, ejbCreate could be invoked much earlier for a stateless session bean unrelated to any calls from the client.

So, how can getEJBObject be a valid operation in ejbCreate for a statless session bean ?
No, I did not resubmit.
20 years ago
The instruction says:
"The remote client code that you write must provide all the public methods of the suncertify.db.Data class. "
Why are they specifying remote client?
I am under the impression that- in the network mode the server is "remote" and, the client is local in the non-network mode.
The client does not implement Remote interface in either mode.
If such questions are asked in the exam, should we look for just method names or the exact signature/argument list etc ?
Which are the valid methods in java.awt.Graphics class ?
1. drawRect()
2. fillRect()
3. drawOval()
4. drawString()
As there are no arguments in the options, I am tempted to say none of the above are valid methods.
Annonymous classes are never static even if it's in a static context.
What about the local inner classes in a static method ?
Why static declarations are not allowed in the following ?
I have this:
class Test{
int i;
static void test(){
class Test1{
static int j // This complains..that inner classes
// cannot have static declarations

int k = i; //this complains, as non-static variable
//cannot be accessed from a static context
From JLS 5.1.2:
int big = 1234567890;
float f = big;
System.out.println(i - (int)f);
is not 0, as the float values are not precise for nine significant digits.
Going by the same, I was not expecting to get a 0 when I used, Integer.MAX_VALUE for 'big'. Why is that 0 ?
In the Object class, why are only the methods clone and finlaize have protected access ?
My understanding for providing the protected access modifier is to provide visibility for subclasses in different packages.
java.lang package is available by default and all classes extend the Object by default.
I thought the following should work. But, I get a ClassCastException in I, whereas II works fine. What's the difference between I and II ?
class Test{}
class Test1 extends Test{}
<some method>....
Test t[] = {new Test1(), new Test1()};
//ClassCastException, here:
Test1 t1[] = (Test1[])t;
<some method>....
Test t[];
Test1 t1[] = {new Test1(), new Test1()};
t = t1;
Test1 t11[] = (Test1[])t;
The same thing works in the context of an applet, however.
Like in the code:
class Test extends Applet{

Image img;
public void init(){
img = createImage(100,100);
//Image is created it.
createImage is in java.awt package, defined in Component class.

I am not sure what is wrong here. createImage is always returning null. What's the usage of createImage ?
class Test extends Panel{
Image img;
public Test(){
img = createImage(100,100);
// After this, img is always null.
From JLS 8.6 :
An instance initializer of a named class may not throw a checked exception unless that exception or one of its superclasses is explicitly declared in the throws clause of each constructor of its class and the class has at least one explicitly declared constructor. An instance initializer in an anonymous class (�15.9.5) can throw any exceptions.
I thought the following code should compile. What is wrong here ?
public class Test{
// I get an error here: unreported exception TestException; must be caught or declared to //be thrown
void print() throws TestException{
Test() throws TestException{
class TestException extends Exception{}
Just giving a shot at this one, not sure if it makes enough sense.
I think, you need to connect lot of things together here.
From JLS 8.6:
"It is a compile-time error if an instance initializer cannot complete normally "
From JLS: 14.20
"A break, continue, return, or throw statement cannot complete normally"

Hence the following code will give a compiler error ('initializer must be able to complete normally') .
class Test{
throw new TestException();
class TextException extends RuntimeException{

Also from JLS 14:20,
"HYPOTHETICAL: An if-then statement can complete normally iff at least one of the following is true:
The if-then statement is reachable and the condition expression is not a constant expression whose value is true.
The then-statement can complete normally
So, the following code compiles fine as, if-then statement is considered to complete normally (since if statement is reachable) and hence the instance initializer itself is considered to complete normally.
class Test{
if(true) // or if(false)
throw new TestException();
class TextException extends RuntimeException{
Can someone explain this (preferably with an example)?
From JLS, to choose the most specific method:
If all the maximally specific methods have the same signature, then:
1. If one of the maximally specific methods is not declared abstract, it is the most specific method.

2. Otherwise, all the maximally specific methods are necessarily declared abstract. The most specific method is chosen arbitrarily among the maximally specific methods. However, the most specific method is considered to throw a checked exception if and only if that exception is declared in the throws clauses of each of the maximally specific methods
How can the method be chosen arbitarirly (the 2nd point) ? Shouldn't there be compile-time ambiguous error , if, there are more than one maximally specific method ?