Help coderanch get a
new server
by contributing to the fundraiser

Srinivasan Krishnan

Greenhorn
+ Follow
since Nov 07, 2000
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 Srinivasan Krishnan

Private Methods belongs only to that class, not even to the extending class, and so it cannot be overridden. Hope I am right
My next doubt is that the String which is created as specified above (in the question) will be created in the String Pool (I guess String Pool is a Stack) Will an element in Stringpool be considered for GC by JVM ?
Please clarify.
Can any one tell me as why 'C' is not added with the list of valid method in Question 1.
Thanks
I apologize. The line that needs to be removed is "K = 0". It is immediately above the For Loop having "K++;". I am getting an error message java.lang.ArrayIndexOutOfBoundsException.
I repeat, my question was should we need to intialize the array index every time?
Remove the "line in question" and then try the pgm. It gives the exception.
Please look in the following program. Is it mandatory to initialize the index variable before accessing any area? The reason I am asking this question is with out reassigning the value of the index variable (here it is 'K') I am getting an error indexoutofbound exception.
Can someone explain, Please...
class GC
{
public static void main(String args[])
{
int i[] = new int[6];
int k = 0;
for(int j = 1000; j < 1006; j++)
{
i[k] = j;
k++;
}
for (int j = 0; j < 6; j++)
{
System.out.println(i[j]);
}
i = new int[10];
k = 0;
for(int j = 1000; j < 1010; j++)
{
i[k] = j;
k++; //Line in question.
}
for(int j = 0; j < 10; j++)
{
System.out.println(i[j]);
}
}
}
Thank you
Hi
I was try the following code. It compiled file but while running this code I am getting java.lang.ClasscastException. I don't know as why I received this Exception.
Class Superclass
{
int i = 5;
public Superclass()
{
System.out.println("I am in Super Class");
}
public void Method()
{
System.out.println("I am in Method of Super Class");
}
}

class Subclass extends Superclass
{
int i = 10;
public Subclass()
{
System.out.println("I am in Subclass");
}
public void Method()
{
System.out.println("I am in Method of Subclass");
}
}

public class HierarchyInitialization
{
public static void main (String args[])
{
Subclass sb = (Subclass) new Superclass();
sb.Method();
System.out.println("I have completed");
}
}
Can anyone give me the reason, Please.
Krishnan.
Hi,
This is my first entry into Java Ranch. I read Mr. Suresh replay to the above subject. At the end he had given an information that the result of unsigned right sift on an -ve integer is always positive is FALSE.
But in Mr. Sahir's reply it is mentioned as unsigned right shift will always introduce 0 in the MSB. When 0 is inserted it should be positive.
Pl. clarify as how the information given by Mr. Suresh be False
Tanx.