r balasubramanian

Greenhorn
+ Follow
since Jul 25, 2001
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 r balasubramanian

Test r=new Test(i) is not a single statement. It is a block of statement. First we are declaring a variable and then we are assignment a value for the same. Hence, it has to be within the curly braces.
R.Balasubramanian
Hi Jane
Your explanation is interesting. But, I feel when an object is not initialised its default value is null. Since the objects with a value of null is eligible for GC, all the objects in the examples are eligible for gc. If I am wrong please explain me with more details. Thanks
Balasubramanian
I feel, since all the objects are null (you have only created an object using new operator and nothing has been referenced), all the three objects are eligible for gc. Correct me if I am wrong.
Balasubramanian
In continuation to my previous posting please note that static inner class can have static members
R.Balasubramanian

Originally posted by Alex Sbityakov:
Hi all,
Is the following statement true?
Variables defined inside inner classes cannot be static unless the inner class itself is static.
But it is true that non-static inner classes can have static final variables. I've seen the statement above taken to be true in a few mocks. What should I make of it?
Thanks


Yes, it is true. Only top level classes and interfaces can have static members.
R.Balasubramanian
Sorry, null is not a key word (perhaps typing mistake). however, please note that true, false and null are literals and hence we cannot use it as int null=10
R.Balasubramanian
Yes, null is a key word
Whenever you give you a prefix of 0 to any binary, compiler will treat it as octale only.
Hi Gong,
Since an inner class can access only the members of enclosing the class, in this case method2 can access only method1 of class B.
If you have any other answer, please mail me at pillaiyar72@hotmail.com
R.Balasubramanian

Originally posted by james gong:
read the code which can the method2 access without reference ?
//*****************code*************//
class A
{
public int x;
public int y;
class B{
protected void method1(){};
class C
{
protected void method2(){}
}
}
}
//***********code_end**************//
key:the x,y,method1 are the method2 can access without reference;


Hi lashkar;
Since you are trying to print individual elements in the arrange, try a for loop as follows:
public void amethod(String[] arguments) {
for (int i=0; i<arguments.length; i++){>
/* Here */ System.out.println(arguments[i]);
}
System.out.println(arguments[1]);
}
my email id is pillaiyar72@hotmail.com
R.Balasubramanian

Originally posted by lashkar:
public class TestClass
{
public static void main(String arguments[]) {
TestClass tc=new TestClass();
tc.amethod(arguments);
}
public void amethod(String[] arguments) {
/* Here */ System.out.println(arguments);
System.out.println(arguments[1]);
}
}
===============
if I run it with
java TestClass string1 string2
the output :
------------
[Ljava.lang.String;@2d8
string2
======
I thought there would have been a Runtime error as "arguments"
should not mean anyting without an INDEX .
Can you enlighten me ?
Thanks.
ML


Hi Nilesh,
The output will be "String: null" and "String: Priyanka".
When the subclass is instantiated, the default constructor of the superclass will be called. In this case the constructor of superclass will call the method nameString(). Since the this method is overridden in the subclass, the nameString() method of the subclass will be called. At this stage String will be null, since nothing has been assigned to this variable. Note that instance variables will be initialised with their default values when they are not initialised by the programmer. Hence, the above output.
My email id is pillaiyar72@hotmail.com
R.Balasubramanian

Originally posted by Nilesh Kadu:
Hi,
Pls let me know the o/p of following program, but pls be sure to explain the things given out.
Thanks for u r attention.
Nilesh.
class superclass{
protected String String;
superclass(){
nameString();
}
public void nameString(){
String = "Aishwarya";
System.out.println("String: "+String);
}
}
class Q29 extends superclass{
private String String = "Priyanka";
Q29(){
nameString();
}
public void nameString(){
System.out.println("String: "+String);
}
public static void main(String[] args){
new Q29();
}
}