Puja Sinha

Greenhorn
+ Follow
since May 25, 2011
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Puja Sinha

What is the answer for the following question :

What does polymorphism mean?
Choice 1
Dynamic selection of underlying proxies
Choice 2
A class can have different behavior depending on its runtime type.
Choice 3
A clever form of inheritance
Choice 4
It is another name for the Object-Oriented paradigm.
Choice 5
Dynamic behind the scene code conversion (for example, byte codes to native machine
code)
Hi,

I ran the following code :



It printed :


This is the parent class
parent



Why does this happen , when we say that the static members are not inherited.

Thanks in advance.
Puja
Hi All,

I want a precise and good book to understand the design patterns. Pointers will be appreciated. Also, in case there are any PDF's available please send them out to me!

Thanks in advance.

Puja Sinha
13 years ago
Can one object access a private variable of another object of the same class ?
Hi Robin,

Thanks for your response.
But as per the javadoc you have attached :

Robin John wrote: Some platforms, in particular, allow a file to be opened for writing by only one FileWriter (or other file-writing object) at a time. In such situations the constructors in this class will fail if the file involved is already open.



Does it mean that if there are two threads trying to work on the same file and one thread already has the file opened up then the other thread will fail to get an instance of the writer object ?

but if one thread has written to and closed the file, then the other thread will overwrite that file and open it ?
Swastik,

Print d1.weight and you will get 42
Hi,

What's the difference between

String str = "abc";

and

String str = new String("abc");

Regards,
Puja
Hi,

Why and how is the linkedList good for fast insertion and deletion while the arraylist good for fast iteration and retrieval?

Also, why and how is the LinkedHashMap fast for iteration and slow for insertion and deletion ?


Regards,
Puja
Hi,


When we try to the run the above mentioned code using :
java Regex "a?" "aba"
should produce something very similar to this:
Pattern is a?
0 1 a
1 1
2 3 a
3 3

How do we get this? What is the concept of zero-length matches and the I totally fail to understand the greedy and reluctant qualifiers
Please help.

Thanks in adv.
Hi,

In the following code when we deserialize the dog object the Animal class constructor is run and the weight variable gets the value of 42 instead of the value it had when the dog object was serialized.

But when we serialize the dog object is the value of the inherited weight variable also saved or not ?



Thanks in adv.
Hi,

Can we replace the following piece of code with the one listed below it?



Replace with
Hi,

the book says :

Inner class in a static method has no access to instance variables.



Then can we instantiate an inner class defined in a static context as inner class objects need to tied to an outer class object and there is no this in static context?

If we can instantiate such a class what would be it's use (it would be great if stated with an example).

Thanks in advance.
Hi,

What does the author mean when he says :

The inner class object cannot use the local variables of the method the inner class is in, Unless the local variables are marked final!



Regards,
Puja
Hi,

Are the static variables inherited by the subclasses. I know for sure that the static methods are not inherited but what about the static member variables of a class ?

Regards,
Pooja

Thanks Faraz. So when we say nonpublic methods can use assertions to test the method arguments, do we include the protected methods in it as well ?