Sathishkumar Ethiraju

Greenhorn
+ Follow
since Nov 23, 2006
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 Sathishkumar Ethiraju

do you mean
Integer i1 = Integer.valueOf("1"), i2 = Integer.valueOf("1"),
i3 = Integer.valueOf("150"), i4 = Integer.valueOf("150")
System.out.println(i1==i2);
System.out.println(i3==i4);

will result in
true
false

i am getting
false
false
Could you figure out how objects will be there in heap now
after executing the below statement

String a = "a",b = "a",c = new String("a");
Consider the above code edited

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 b4 = color1 instanceof Blue;
boolean b2 = color2 instanceof Blue;
System.out.print(b1+","+b2+","+b4);
}}

I think only at runtime the object refered is considered, at compile time the reference is considered.

color1 is of type Color, it can get both red or blue object, so we cant decide what is the object is passed at compile time.

color2 is of type Red, it can hold only red and not blue, so compile error is got implys that color2 cant be an instanceof blue at all

Hence at compile time, object's reference hierarchy is considered
and at run time, object hierarchy is considered
128 >>> 2
with sign
128 >> 2
without sign

abv 2 won have diff

-128 >>> 2
with sign


-128 >> 2
without sign

in the case of >>> MSB will also get shifted
0 is the msb in case of positive numbers
and 1 for negative numbers
John,
do you mean
Class {
int a = 10;
}
also wont't work

What is the difference between
int a[] = new int[5] and int a = 5 being outside the method in a class
is that creation of an Array instance matters
we were passing a String to the Constructor which in turn will create a Sting, Am i right ?
Hey John,
Could you be please clear on
return a-b; is illegal since the hashCode is different for negative numbers.
"System.out.println(Float.NaN==Float.NaN);" returns false
------ Coz in abv statement two different reference were compared
Float f1=new Float(Float.NaN);
Float f2=new Float(Float.NaN);
System.out.println(f1.equals(f2)); prints true..
------ here true, coz equals method will be overrided to compare the actual values, not the references. Am i right ?
Congrats Ahmed. Could you please share how you prepared,
will you share some masterpiece questions you have
17 years ago