Seany Iris

Ranch Hand
+ Follow
since Jan 08, 2002
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Seany Iris

Question ID :957672686580
Consider following two classes:
//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() );
}
}
What will be the output of compiling and running class B ?
Good luck!
please tell us how about it when you finished it!
I cann't see,why?
Is it available still?
Great!I got it.
thank you val!
I am very confused:
Math.IEEEremainder(3,5)==-2.0,while Math.IEEEremainder(2,5)==2.0
who can explain it to me?
yes,i got it,thank you all.
Why cann't the code compile?
class TestClass
{
int i = 9;
i = getInt();
int k = 20;
public int getInt()
{
return k + 1; // < -- A
}
public static void main(String[] args)
{
TestClass t = new TestClass();
System.out.println(t.i + "" + t.k); // <-- B
}
}
run it in my computer, the output is 120, which as my expectation.
Who can explain "String literels will never garbage collected. " to me?
yes, i see.
thank you all!
yes,manikandan v,I think you are right.
the operater "||" will cause short circuit,only the left pression is false,the right pression will caculate. so
4 if ((s ==null) || ( i =s.length()))
if (s == null) is false, that means s != null, it can't throw exception.otherwise, the right pression cann't be caculate.
But as concerning 3if ((s !=null) || ( i =s.length()))
if (s!= null) is false, that means (s == null),and the pression (i = s.length) will throw nullPointerException.
In a file, there may be more than 1 top-level class,isn't it?
and cann't be private or protected?
who can explain what the top-level class is?
I had found that early before. yes, Rob help us very much! thank you, Rob!