Originally posted by sdev:
What is the result of the following frament of code:
int a=0x67;
int b=0xBD;
a^b
a.0xFF
b.0xDA
c.0x25
d.0xAA
Answer is b
Anyone please explain how the answer is b.
Originally posted by mikeliu:
Hi All,
Please help me clear the doubts.
What will happen if you attempt to compile and run the following code?
1) Compile and run without error
2) Compile time Exception
3) Runtime Exception
1.class Base {}
2.class Sub extends Base {}
3.class Sub2 extends Base {}
4.public class CEx{
5. public static void main(String argv[]){
6. Base b=new Base();
7. Sub s=(Sub) b;
8. }
9.}
I chose the 1, but the answer is 3. I am totally confused! because in RHE, it is ok to case the object reference at run time if one of classes must be a subclass of the other(it doesn't matter which one)(please refer to page118-119 in RHE if you have RHE). Am i missing something?
Mike
Originally posted by tom gong:
I do not understand why line 2 compare a String created at runtime?
1. String java = "java", va = "va";
2. System.out.println(java == "ja"+va);
please help me to understand it,
thanks for help,
tg