Malini Santhanam

Greenhorn
+ Follow
since Jul 20, 2004
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 Malini Santhanam

Thanks fred...I interpreted Dan's explanation incorrectly..
Hi,

I came across this question in Dan's site under Operators.

class Color {}
class Red extends Color {}
class Blue extends Color {}
class A {
public static void main (String[] args) {
Color color1 = new Red(); Red color2 = new Red();
boolean b1 = color1 instanceof Color;
boolean b2 = color1 instanceof Blue;
boolean b3 = color2 instanceof Blue;
System.out.print(b1+","+b2+","+b3);
}}

Why should this code give a compile time error? I was under the impression that instanceof operator can only return a boolean value?Please clarify..

Thanks,
Malini
Can anybody let me know why the following code will not compile? This is one of the question from JQ plus test series.

//in file A.java
package p1;
public class A
{
protected int i = 10;
public int getI() { return i; }
}

//in file B.java
package p2;
import p1.*;
public class B extends p1.A
{
public void process(A a)
{
a.i = a.i*2;
}
public static void main(String[] args)
{
A a = new B();
B b = new B();
b.process(a);
System.out.println( a.getI() );
}
}

Thanks,
Malini
Can anybody let me know when an object is eligible for garbage collection with some examples?

Thanks in advance,
Malini
17 years ago