This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Svelte and Sapper in Action and have Mark Volkmann on-line!
See this thread for details.
Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!

Sharmistha Sarkar

Ranch Hand
+ Follow
since Dec 18, 2012
Cows and Likes
Cows
Total received
1
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
2
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Sharmistha Sarkar

Hi, I want to make a desktop application(java with mysql/mongodb=please suggest if mysql/mongodb is secure and without crash) which will work for particular paid customers. This case, 1st option is, I can make a password protection. I can make that. Now my doubt is, if my business grows vast and I get 1,00,000 clients, then initially I can physically meet them and install the software but what if somehow their laptop got crash and they loose the software, it would be difficult to travel their place just for typing password and re-install the application. Is there any way that I can give them a backup of the application in some external drive (like pen-drive), and code something like only one time they can use the pendrive so that they can not distribute that software to their friends. Do anyone ever create any software and sold to people? if yes , then how could it be protected so that I can have the control of installing every time to every client and they could not be able to distribute among them? Any help would be appreciable. Regards,
Sharmistha
4 years ago
I am trying to find prime number from an given array. I could see 3 is a prime number in my array but it is printing as NOT prime number. But if I remove other numbers and keep only 3 in this array, 3 prints as prime number only. Could anyone suggest what is the problem going on here ?

4 years ago
Thanks everyone. Jesper de Jong has cleared the doubt well.
4 years ago
While writing a program, in which situation should I use For loop and when to use enhanced for loop? both results same. Is there any situation anyone ever faced ;when you could not get the result using for loop and had to use enhanced for loop or vice versa?
4 years ago
Hey all, I am little idiot to understand this yet. I don't understand why it doesn't show result as 1 0 3 0. As per the explanation, he also says 1 0 3 0. How this changes to 0 0 3 0 ?? Regards,
Hi, I am trying to understand what DefaultHandler class does in SAX parsing?
5 years ago
Can you please tell me which one is the overriding method here and which one is overridden method?

Consider, this example.

6 years ago
Hi Winston,

I am clear with my 2nd Question answer.

1. What is the rule for creating Covariant Return Type overriding?

Answer: the return types of the overriding methods [must] be subtypes of the return type of the overridden method




I know it's damn silly , but I really didn't understand the meaning of the sentence.

Let me elaborate it,

overriding methods meaning : Here from my above example, B print1() method = inside class B is Overriding method. It should return B class object.


overridden method meaning : A print1() method = inside Class A. It should return Class A Object or constructor but I am returning class B constructor.


Now if the above two are correct then just want to know; what is the meaning of " overriding methods [must] be subtypes ". What is that subtypes mean?


I am sorry for confusing you.

My 3rd Question is : whether Covariant Return Type would be class constructors or objects only? or it could be primitive data types like int,void etc...?
Example , I gave print1() with class A or class B return type...whether it could be int or float etc?


Regards,
Sharmistha
6 years ago
Hello All, I am trying to understand the Covariant return type.

I am unable to understand the definition of Covariant Return Type , as it says " the return types of the overriding methods will be subtypes of the return type of the overridden method".......I am unable to understand this English sentence.


However I did a sample .



I want to know,
1. What is the rule for creating Covariant Return Type overriding?
2. Why it is necessary in Java? What if it is not been introduced, were people getting any problem prior to this?
3. Is method Return type should be Class objects only?


Thanks,
Sharmistha
6 years ago
Hello Ulf,

I have made the variable static. It is working fine. I don't find reason to make it volatile, because it is visible to all threads.

Here is my modified code,

Hi All,

I am facing issue in thread Synchronization. I have created a variable called accountBalance; where I am storing 20,000.00 . I am creating 10 threads to debit 2,000.00 from the same variable. I want after 10th thread debit 2,000.00 from accountBalance, My final accountBalance should be 0000.00. But every time for every thread I am getting output 18,000.00. It should come like Thread 1 18000.00, Thread 2 16000.00 like this...


i don't know now how can I make the threads not being short-living. I am not a very good programmer.
I really didn't understand why should I use volatile.

It's is about visibility of a global variable which I know. But when should I use this volatile keyword ? At what circumstances ?

If the code which I created; is not correct then can anyone create some other program or modify my code and explain?

Regards,
Sharmistha
yes yes , I also noticed without a notify() also it works when I give wait(100).

As already mentioned, if the notification is sent before the other thread waits, the other thread will wait forever, as the notifications without any threads waiting is discarded.



Now, is there any tricks is there to complete the waiting of a thread and then sends notification....I am little confused here. let me give you another example; I found in some site , where wait() and notify() works properly. So what is the difference between my code and the below code?





OUTPUT:

Producer thread running ....
Waiting for return key.

Return key pressed.
Resumed.

Thanks,
Sharmistha
Hi Henry, I am getting below output of my program .

started.......
It is notify block .......

But if I give wait(specify some time) then the program runs as expected.
I mean to say, I gave wait(100) instead wait() in the program and Output shows,

started.......
It is notify block .......
Thread woke up now .......
End of code .......

This is what I want. After notify() calls it goes back to the wait() related synchronized block again and executes the remaining of that block and then comes out and prints the last statement.
Could you please explain what is happening here?

Regards,
Sharmistha