Mafalda Alabort

Greenhorn
+ Follow
since Mar 02, 2001
Merit badge: grant badges
For More
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 Mafalda Alabort

Hi all,
I passed the programmer's exam this morning and just wanted to thank everybody who makes this site or participates in the forums. You have been a great help.
The questions on threads were really nasty but I found the questions on java.lang and java.awt are not hard and you can answer them quickly without having to look through loads of code.
Good luck to all the aspirants.
23 years ago
Marilyn,
cannot you create an instance of the static inner class (or top level nested class) as
OuterClass.InnerClass inner = new OuterClass.InnerClass() ?
Thanks
Hi,
If you look in the API those methods are called asin(), acos() and atan() all in lowercase.
I hope they dont ask questions like this in the exam.
Hi,
Question 49 in exam Bonus 1 says:


Consider the following class definition:
public class Parent {
final void zzz() { }
}
Which of the following methods may appear in a subclass of Parent, when the subclass is in a different package from Parent?


The option A) void zzz() { } is given as wrong.
I know final methods cannot be overriden, but these two source files compiled successfully:
<pre>
package p1;
public class X{
final void aMethod(){}
}
</pre>
<pre>
package p2;
import p1.X;
public class Y extends X{
void aMethod(){}
}
</pre>
I supose it compiled because class Y cannot see aMethod() in X. It is the same as when I can declare a method with the same name and argument list that another final and private one in a superclas. Please correct me if I am wrong.
And shouldn't answer A be given as correct then?
Thank you
[This message has been edited by Mafalda Alabort (edited March 25, 2001).]
[This message has been edited by Mafalda Alabort (edited March 25, 2001).]
Durga,
when timeout expires the thread moves to the seeking lock state.
It explicitly says so in the Java 2 Certification Study Guide.
I hope it helps.
Hi,
I think initialization occurs on constructor invocation, after execution of the superclass constructor and before execution of the body of the constructor itself.
Please correct me if I am wrong.
Hi Nitin,
int i= 3;
i*=2+i++;
we can put it as i=i*(2+i++)
then first evaluate and then asign
i=3*5
i=15
if we did
i*=2+(++i);
then i would be 18

[This message has been edited by Mafalda Alabort (edited March 24, 2001).]
Hi,
When an overloaded method gets called, the compiler chooses the one with the same argument type as the argument in the call.
But what if the argument of the method call doesn'nt exactly match the arg type of any of the methods, but can be converted to match the argument type in more than one method. Which one does the compiler choose? Does it choose the closest one in the conversion chain?
Here is an example:
<pre>
public class OverLoad{
public void aMethod(int i){
System.out.println("int version : " +i);
}
public void aMethod(long l){
System.out.println("long version : " +l);
}
public static void main(String [] args){
byte b = 2;
OverLoad ol = new OverLoad();
ol.aMethod(b);
}
}
</pre>
The output is "int version : 2"
Why exactly is it choosing aMethod(int i) ?
Thank you.

[This message has been edited by Mafalda Alabort (edited March 24, 2001).]
Thank you Bala and Huiying
Hi,
I compiled and run this code. It seems that 100.0/-0 s positive and 100.0/-0.0 is negative. So there is a negative zero for doubles but not for ints?. Is there any explanation for this?
<pre>
public class A1{
public static void main(String [] buff){
//double d = 100.0/-0.0; // outputs negative infinity
double d = 100.0/-0; // outputs positive infinity
if(d == Double.NEGATIVE_INFINITY){
System.out.println("NEGATIVE_INFINITY");
}else{
System.out.println("POSITIVE_INFINITY");
}
}
}
</pre>
Thank you very much
Hi,
When you override a method, the overriding method cannot throw any checked exception not thrown by the overriden one.
So if a method m() in class Super throws a IOException and we override m() in class Sub that extends Super, then if m() in Sub declares that throws any checked exception, they have to be IOException or a subclass of it.
So the method in Sub3 is ok

Hi,
A constructor will call the no arguments constructor in the superclass, so you'll get the compile error because dont have access to it.
You didn't define any constructors in B, but the compiler will still generate one.
This code will compile as you explicitly call another (non private) constructor:
class A{
private A(){}
A(int i){}
}
public class B extends A{
B(){
super(2);
}
}
Hope it helps
[This message has been edited by Mafalda Alabort (edited March 21, 2001).]
Hi,
It should'nt give you an error as you are dividing by 2 and not 0.
In the second question, the code first checks whether the object is an instance of C, if this is true it means that the object was created by instantiating class C or any of its subclasses (class D). So then it checks whether it is not an instance of D.
Hi all,
The narrowing conversion would normally not be allowed without a explicit cast. The exception is when we assign a literal to a variable. In this case the compiler calculates the target's size and "implicitly casts" the literal i fhere is enougth room in the target.
It is exactly the same as when you do:
byte b = 40; // this is ok
byte b = 4000; // compile error : possible loss of precission
Both 40 and 4000 are of size int. The compiler checks that 40 could be represented by a byte and automatically casts it.
I know I am not being very clear, but I hope it still helps.

Hi,
if you want to use the static vbles x and y, do not declare them again inside main().
When you say "int x =" you are declaring a new vble local to the method. If you get rid of "int" inside the main() method, the code will work:
public class A{
static int x=10;
static int y=10;
public static void main(String[]args){
x=x++ + y++;
System.out.println(x);
}
}
I think.