Santosh Kumar Nayak

Ranch Hand
+ Follow
since Aug 02, 2011
Santosh Kumar likes ...
Eclipse IDE IntelliJ IDE Java
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
4
Received in last 30 days
1
Total given
14
Given in last 30 days
4
Forums and Threads
Scavenger Hunt
(keep public parts private until JForum day)
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt
Moderation Tools

Recent posts by Santosh Kumar Nayak

Norm Radder wrote:

Both the java programs would be using the same JVM ?


No. I think each execution of the java program would start its own JVM.  On Windows you can see separate processes by using the Task Manager.

On Windows there is some magic where the OS will give a running program a chance to open a file within an existing process.  For example open a PDF file in Adobe and then try to open a second PDF file, it will be opened in the running program in a new tab.




Thanks a Lot. You made my Day     
1 week ago

Norm Radder wrote:

why it is not Sorted


Please explain why you do not think it is sorted.



Look at the Output Provided
1 week ago
Hi All,

I am trying this solution to get TOP10 elements using java.util.PriorityQueue

But I am getting the output as :-
smallest1: 1
smallest2: 1
FULL Q [1, 2, 2, 4, 8, 5, 3]

Not sure as why it is not Sorted.



1 week ago

Campbell Ritchie wrote:You are adding 14 elements to the List; you will get faster execution if you initialise its capacity to 14. Obviously for such small numbers, the time differences will be small.



I was trying to define fixed sized ArrayList  
1 week ago
Each JVM is a separate process, and that means there is no sharing of stacks, heaps, etcetera. (Generally, the only things that might be shared are the read only segments that hold the code of the core JVM and native libraries ... in the same way that normal processes might share code segments)
The JVMs are independent processes. They don't share any mutable state. Garbage collection operates on each JVM independently.

Now suppose 2 java programs are running on same Laptop.If 1 program encounters java.lang.OutOfMemoryError: Java heap space

Will the 2nd program also get the same error ?




1 week ago

Stephan van Hulst wrote:What are you going to do if you want to change the application properties programmatically, while running? Surely you're not going to modify the global instance, are you? And how are you going to unit test classes whose behavior depends on application settings?

Application settings are NOT a good example.




Hi

Using a program we would not intend to change value of Application Properties file
This option just makes Interviewer mouth keep shut on further questions 
1 week ago
Hi

Create a HashMap and insert elements into it
Override Hashcode method and DO NOT OVERRIDE equals method. Then by default you would be using Object class equals method

Make sure you try the same using same KEY also

Then try to retrieve the elements then you shall see the difference by yourself


1 week ago
Hi Saurabh

Real life example of Singleton example : Reading Application.properties file using Singleton Instance

I usually say the same in an Interview 
1 week ago
So specifying the ArrayList size does not mean anything to JVM
Internally basic implemention of arraylist  will work
1 week ago
ArrayBlockingQueue in the JDK already has this use case, and it throws IllegalStateException in the case where the collection is already full.
https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ArrayBlockingQueue.html#add(E)
Throws: IllegalStateException - if this queue is full





The above code does not throw any kind of Exception .Why so ?
1 week ago
Thats the design and behaviour of static. As static belongs to Class so it remains with class and not with instance of Class
Overriding will break its connection with Class Level.Also it will become victim of Dynamic Polymorphism
1 week ago
On a Collection, say an ArrayList  I did a sort : O(n(log n))
Then I did a linear search : O(n)

On total what is the time complexity.How to compute the same ?
Do we have any Upper size limit for CachedThreadPool ?
Read this.It will help you clear your idea on Type erasure

webpage
1 month ago