hi
got some doubts. Please help me out .
1.What is the result that will be printed out here ?
int i = - 128;
System.out.println((byte)i << 1);
answers 1: -256
2: 256 .
Correct answer is -256. but i thought it would be 256.
2.Will this
test evaluate to true?
Object a = "hello";
String b = "hello";
if(a == b)
System.out.println("equal");
else
System.out.println("not equal");
Answer given is "Yes". but when i compile i get the following 2 errors.
error: incompatible types
found: java.lang.String
required: Object
Object a="hello";
error: incomparable types: Object and java.lang.String
if(a==b)
Thanks in advance.