java.interviews.questions
BAN USER
JAVA developer and designer
- 0of 0 votes
AnswersDifference in SOAP and IIOP?
- java.interviews.questions in India| Report Duplicate | Flag | PURGE
Citigroup Java Developer Java - 0of 0 votes
AnswersWhat is externalizable interface?
- java.interviews.questions in India| Report Duplicate | Flag | PURGE
Citigroup Java Developer Java - -3of 3 votes
AnswersWhat is spring Initialization Bean interface?
- java.interviews.questions in India| Report Duplicate | Flag | PURGE
Citigroup Applications Developer Java - -3of 3 votes
Answerswhat is generic Eraser in java?
- java.interviews.questions in India| Report Duplicate | Flag | PURGE
Citigroup Applications Developer Java - -3of 3 votes
Answersdecide collection in java where you can store this range based search?
- java.interviews.questions in India
age range : group id
0-25 : 1
26: 50 : 2
> 51 : 3
best way to store this DS and In search input is age and we should get group id?| Report Duplicate | Flag | PURGE
Citigroup Applications Developer Java - -3of 3 votes
Answerwhen to use serialization vs externalizable interface?
- java.interviews.questions in India| Report Duplicate | Flag | PURGE
Citigroup Applications Developer Java - -3of 3 votes
AnswersIf new object is created by thread then where object's attributes are going to be created? stack or heap?
- java.interviews.questions in India
class Myclass{
String data;
MyObject object;
public void mehtod(){
data = new String("ddd");
object = new MyObject();
int i = 10;
}
Suppose now thread A creates object of this class and calls method() then where data, object and i will be created? heap or stack of thread?| Report Duplicate | Flag | PURGE
Citigroup Applications Developer Java - 0of 0 votes
AnswersDesign high throughput trading application? Application is hosted in NY and we have traders all over the world accessing this application. What things we need to take care on designing this application.
- java.interviews.questions in India| Report Duplicate | Flag | PURGE
Goldman Sachs Java Developer Java - -1of 1 vote
AnswersRemoving duplicates from unsorted list of integer?
- java.interviews.questions in India
if you have unsorted list of
0,5,9,5,6,7,6,9
the result should be
0,5,9,6,7 and the performance should be best over more number of elements.| Report Duplicate | Flag | PURGE
Goldman Sachs Java Developer Algorithm - 0of 0 votes
AnswersHow to create singleton class and what if the constructor is throwing IOException? what will be best strategy to create instance of this class?
The question is more on constructor throws exception.
- java.interviews.questions in United States//create singleton class. private SingltonExample() throws FileNotFoundException { File f = new File("data.txt"); FileInputStream fis = new FileInputStream(f); }
| Report Duplicate | Flag | PURGE
Goldman Sachs Java Developer Java
I am not sure if you were looking for View as option. Which will disconnect external system from our table dependency. and any change in table will not be transparent to them.
- java.interviews.questions October 07, 2013you are correct and after this compiler removes the generic type and at runtime it is executed without specific type. This is called generic Eraser. I came to know this concept in interview itself.
- java.interviews.questions October 07, 2013Thanks @Ehsan for details.
- java.interviews.questions September 19, 2013This is not threadsafe as StringBuilder reference can be changed by any other thread.
- java.interviews.questions September 13, 2013The logic is if some number is top N in table then there will be (n-1) number more than that in table take a example
you have 9,8,7,6 in table as id and Top 2 will have only one number more than that so it is used
1 = SELECT COUNT(DISTINCT(Emp2.Salary))
FROM Employee Emp2
WHERE Emp2.Salary > Emp1.Salary
public class ConcurrentLRUCache<Key, Value> {
private final int maxSize;
private ConcurrentHashMap<Key, Value> map;
private ConcurrentLinkedQueue<Key> queue;
public ConcurrentLRUCache(final int maxSize) {
this.maxSize = maxSize;
map = new ConcurrentHashMap<Key, Value>(maxSize);
queue = new ConcurrentLinkedQueue<Key>();
}
/**
* @param key - may not be null!
* @param value - may not be null!
*/
public void put(final Key key, final Value value) {
if (map.containsKey(key)) {
queue.remove(key); // remove the key from the FIFO queue
}
while (queue.size() >= maxSize) {
Key oldestKey = queue.poll();
if (null != oldestKey) {
map.remove(oldestKey);
}
}
queue.add(key);
map.put(key, value);
}
/**
* @param key - may not be null!
* @return the value associated to the given key or null
*/
public Value get(final Key key) {
return map.get(key);
}
}
Delete data by scheduler using cleanData method.
package com.learning.lru;
import java.util.ArrayList;
import java.util.concurrent.locks.ReentrantReadWriteLock;
public class MyLRUCache {
private ArrayList<Data> dataHolder = new ArrayList<Data>();
ReentrantReadWriteLock lock = new ReentrantReadWriteLock(true);
private final long dataLifetime = 5000;
public Data getData(int i) {
try{
lock.readLock().lock();
if(dataHolder.size() == 0){
System.out.println(" NO Data Found");
return null;
}
return dataHolder.get(i);
}finally{
lock.readLock().unlock();
}
}
public boolean putData(Data d) {
try{
lock.writeLock().lock();
dataHolder.add(d);
return true;
}finally{
System.out.println(" Final Data size "+dataHolder.size());
lock.writeLock().unlock();
return false;
}
}
public boolean cleanData() {
int i=0;
if( dataHolder.size()==0){
System.out.println(" NO Data to clean");
return true;
}else{
System.out.println(" Data Size "+ dataHolder.size());
System.out.println(" lock status "+lock.getReadHoldCount());
}
try{
lock.writeLock().lock();
for(Data d : dataHolder){
if(System.currentTimeMillis()-d.getTimeStamp().getTime() > dataLifetime){
//tempHolder.add(d);
dataHolder.remove(i);
i++;
}
}
}finally{
lock.writeLock().unlock();
return false;
}
}
}
//Client code
package com.learning.lru;
import java.util.Date;
public class LRUClient {
public static void main(String[] args) {
MyLRUCache cache = new MyLRUCache();
LRUClient client = new LRUClient();;
Thread lruc = new Thread(client .new LRUConsumer(cache));
Thread lrup = new Thread( client .new LRUProducer(cache));
Thread lrucl = new Thread( client .new LRUCleaner(cache));
lrup.start();
lruc.start();
lrucl.start();
//use scheduled
}
class LRUConsumer implements Runnable{
MyLRUCache cache ;
LRUConsumer(MyLRUCache cache ){
this.cache=cache;
}
@Override
public void run() {
try {
Thread.sleep(10);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println(" Consuming Data ---------->>>>>>>>");
while(true){
for(int i=0; i<20;i++){
//System.out.println(" DATA :>>>"+cache.getData(i));
}
}
}
}
class LRUProducer implements Runnable{
MyLRUCache cache ;
LRUProducer(MyLRUCache cache ){
this.cache=cache;
}
@Override
public void run() {
try {
Thread.sleep(10);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println(" Putting Data ---------->>>>>>>>");
for(int i=0; i<20;i++){
cache.putData( new Data(i, new Date(System.currentTimeMillis())));
}
}
}
class LRUCleaner implements Runnable{
MyLRUCache cache ;
LRUCleaner(MyLRUCache cache ){
this.cache=cache;
}
@Override
public void run() {
try {
while(true){
//Thread.sleep(3000);
System.out.println(" Cleaning Data ---------->>>>>>>>");
cache.cleanData();
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
In Java definitely concurrent task processing. We need to pick up task concurrently and we can use threadpool or executors to consume these tasks and update the result. We need to take care the database access and query execution should be minimal time consuming.
- java.interviews.questions September 09, 2013
Repinfo@strivashikaranupay.com, Associate at Adap.tv
Are you searching the strong and the most powerful Mantra for your husband? Consult our vashikaran specialist now. He provides ...
Replisafergusona, Consultant at Myntra
I am Lisa from Chicago,I am working as a Show host in the New World. I also work Performs ...
RepPacheTanley, Associate at Adobe
Hi , I am Conference service coordinator for the KB Toys company. I Build and maintain relationships with meeting planners and ...
RepPal A Roos is the best early childhood & child development center in Charlotte. We are famous offering full-time, part-time and ...
RepHad moderate success buying and selling weebles in Ohio. Had some great experience buying and selling wooden trains on Wall ...
Repinfo@kukooo.in, Reverse Engineering and System Developer at Abs india pvt. ltd.
Enthusiastic about implementing wazifa to make someone love you.Prior to my current job I was short selling action figures ...
RepLove is the spice of everyone’s life. Love adds charm and excitement to the monotonous and boring life. If ...
RepPandit Ji is the best vashikaran expert for vashikaran mantra for girlfriend in Mumbai.It is the strongest method to ...
RepAre you looking for strong dua for husband love?Astrology is the perfect way to get your lost love back ...
RepAmber Van is registered and fully insured cheap removal company in Bristol.Our featured services includes domestic moves,commercial moves ...
Reprudystake, Game Programmer at BrowserStack
I am Rudy , a physical therapist with extensive knowledge of sports injuries and therapy . Strong background in athletic coaching and ...
RepOur mission is to provide informative and Self Improvement advice to help people live their lives better set definite goals ...
RepLooking for the best child development center in Charlotte? Pal A Roos provide summer camp for children Charlotte. Our experienced ...
RepStonefire Arms manufacture and bring Firearms parts & accessories to the market at reasonable prices. We offer a wide variety of ...
RepAre you searching for the most powerful and very strong mantra for your husband? If you want to do Jadoo ...
RepMosesanaughe212, Web Developer at Service Now
Hello there everyone,I'm Moses anaughe from Texas , United States. I finished my undergrad contemplates in science and am ...
RepStevenBLuis, Data Scientist at Achieve Internet
Choose the best quality vaping accessories at Ny Vape Shop. With different types of quality vaporizers, we are one of ...
RepDeveloped several new methods for licensing g.i. joes in Los Angeles, CA. Spent high school summers creating marketing channels ...
RepRocioNavarro189, None at Student
Hello Everyone,My name is Rocio Navarro Form Auckland,NZ,and 31 years old.I am searching for a servant ...
RepAre you looking for a simple remedy mantra or solution to seduce your husband? Is your husband not caring about ...
Repsaldanaholly212, Program Manager at Service Now
My name is Saldana Holly from Florida, USA.I originate from a family of 6 youngsters, 3 sisters and 1 ...
RepHave some experience building shaving cream in Mexico. Prior to my current job I was marketing inflatable dolls in Jacksonville ...
RepAre you searching the strong and the most powerful Mantra for your husband? Consult our vashikaran specialist now. He provides ...
RepRosendoVBarhorst, Employee at US
Enthusiastic about implementing wazifa to make someone love you.Prior to my current job I was short selling action figures ...
Repmaccydonal4747, Data Engineer at A9
Hi my sweet companions! My name is Maccy Donal, I conceived in Canada Toronto 1994 and I am unceasingly appreciative ...
impressive!
- java.interviews.questions October 17, 2013