Search Interview Questions | More than 3000 questions in repository. There are more than 900 unanswered questions. Click here and help us by providing the answer. Have a video suggestion. Click Correct / Improve and please let us know. |
|
| ||||
Interview Questions and Answers - Order By Newest | ||||
| ||||
Ans. no, It's like challenging the design of application. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   reflection api   yes-no   architecture Asked in 1 Companies intermediate | ||||
Very frequently asked. Usually followed by questions related to private constructor and synchronized access. Frequently asked in JPMorgan and TCS (Based on 2 feedback) | ||||
| ||||
Ans. http://www.buggybread.com/2014/03/java-design-pattern-singleton-interview.html | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   design pattern   singleton   at&t   ebay  fidelity india  united healthcare india Asked in 46 Companies intermediate   frequent | ||||
| ||||
Ans. No. Enums are final by design. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   enums   inheritance  object oriented programming (oops)  oops concepts   yes-no Asked in 1 Companies intermediate | ||||
| ||||
Ans. A Closeable is an interface which is a source or destination of data that can be closed. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  closeable   interfaces intermediate   rare | ||||
| ||||
Ans. http://www.buggybread.com/2015/01/java-locale-classes-and-interfaces.html | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   util   java.util   locale intermediate   rare | ||||
| ||||
Ans. Collision is the situation when two different elements have the same Hash Code. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   collections   collision   hashcode  hash code   hash collections   ebay Asked in 1 Companies intermediate   frequent | ||||
| ||||
Ans. Static methods are resolved during compile time and hence they cannot participate in runtime polymorphism. Instance methods are resolved during runtime. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   static methods   methods   runtime polymorphism intermediate | ||||
| ||||
Ans. Fail-fast iterators detect illegal concurrent modification during iteration and fail quickly and cleanly rather than risking arbitrary, non deterministic behavior at an undetermined time in future. Example could be of an Iterator failing if it smells ConcurrentModificationException. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  fail-fast Iterators  Iterators Asked in 5 Companies intermediate | ||||
| ||||
Ans. The goal of a synchronised block is to achieve mutual exclusion i.e at one time, the segment of the code should be executed by single thread only and hence the lock needs to be retrieved before executing the segment and then released. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  synchronized block   synchronized   synchronization   multithreading   threads   mutual exclusion   concurrency Asked in 4 Companies intermediate   frequent | ||||
Try 1 Question(s) Test | ||||
Recently asked in Sophos | ||||
| ||||
Ans. http://javasearch.buggybread.com/CodeSnippets/searchCodeSamples.php?keyword=Method+to+get+a+map+of+words&category=code | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  map  collections Asked in 2 Companies intermediate | ||||
| ||||
Ans. http://javasearch.buggybread.com/CodeSnippets/searchCodeSamples.php?keyword=singleton+class&category=code | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  singleton  code  coding  design pattern Asked in 1 Companies Intermediate   frequent | ||||
| ||||
Ans. http://javasearch.buggybread.com/CodeSnippets/searchCodeSamples.php?&category=code&searchOption&keyword=964 | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  builder design pattern  builder pattern  code  coding intermediate | ||||
| ||||
Ans. Yes, with finally. Yes, finally block will be executed even if there is no exception in try block. If finally throws an exception, the exception gets thrown to the calling module. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  exception handling Asked in 1 Companies intermediate | ||||
| ||||
Ans. It depends on whether the request object is persisted as it is or its first dismantled, modified or refactored and then inserted into DB. In first case, it should be a PUT request whereas in second case it should be a POST Request. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  Put vs Post   Rest Asked in 2 Companies intermediate   frequent | ||||
| ||||
Ans. We can use external table feature of Oracle. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve   Asked in 1 Companies Intermediate | ||||
Frequently asked Design Pattern interview question. | ||||
| ||||
Ans. The prototype pattern is a creational design pattern. It is used when the type of objects to create is determined by a prototypical instance, which is cloned to produce new objects. Prototype is used when we need duplicate copies of objects. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  design pattern  prototype design pattern  cloning Asked in 11 Companies intermediate | ||||
Usually asked with Questions related to Generics. | ||||
| ||||
Ans. Type erasure applies to the use of generics. When generics are used, they're pre compiled into compile time checks and execution-time casts. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  type erasures  generics Asked in 2 Companies intermediate   rare | ||||
| ||||
Ans. There is a Java system property "sun.arch.data.model" that can tell if JVM is 32 bit of 64 bit System.getProperty("sun.arch.data.model") can be used to get that property. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  jvm intermediate   rare | ||||
| ||||
Ans. Please not that all such questions can be easily answered through recursion. Simple recursive implementation could be traverse(root); void traverse(Element element){ if(element.hasNext()){ traverse(element.next()); } else { System.out.println(element); } } but this algo / code lead to endless loop if there is a loop in graph traversal. So you can keep a collection to keep track of which elements have laready been traversed static List<Elements> listOfAlreadyTraversedElements = new ArrayList<Elements>(); main(){ traverse(root); } void traverse(Element element){ if(element.hasNext()){ traverse(element.next()); } else { listOfAlreadyTraversedElements.add(element); System.out.println(element); } } | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  graph traversal algorithm  graph traversal algorithm using recursion Asked in 1 Companies intermediate | ||||
Frequently asked in Alibaba (Based on 2 feedback) | ||||
| ||||
Ans. In Java JVM memory settings is done by use the arguments -Xms -Xmx. Use M or G after the numbers for indicating Megs and Gigs of bytes respectively. -Xms indicates the minimum and -Xmx the maximum. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  jvm  memory management  jvm best memory setting Asked in 1 Companies intermediate | ||||
Frequently asked in high end product companies. | ||||
| ||||
Ans. https://www.geeksforgeeks.org/lru-cache-implementation/ | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  cache  LRU cache  coding  code Asked in 10 Companies intermediate | ||||
| ||||
Ans. finally will execute in all graceful situations - graceful executions as well as graceful exceptions. The only situation when finally block won't execute is when the app is abruptly stopped, killed or unplugged. | ||||
Sample Code for finally | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  finally Intermediate | ||||
| ||||
Ans. Interface that is declared inside the interface or class, is known as nested interface. It is static by default. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  interface  nested interface intermediate | ||||
Try 1 Question(s) Test | ||||
| ||||
Ans. Daemon thread | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  garbage collection intermediate | ||||
Try 2 Question(s) Test | ||||
| ||||
Ans. The Reader/Writer hierarchy is character oriented, whereas the Stream class hierarchy is byte oriented. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java io  streams intermediate | ||||
| ||||
Ans. It's an object that reads from one stream and writes to another. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java io  io filter intermediate | ||||
| ||||
Ans. Yes, using InetAddress.getByName("<IP Address>").getHostName(); | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  ip address to hostname  INETAddress intermediate | ||||
| ||||
Ans. It depends on the type of inner class To access non static inner class method new OuterClass().new InnerClass().getMethod(); To access static method of static inner class new OuterClass.InnerClass().getMethod(); | ||||
Sample Code for inner class | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  inner classes  nested aclasses Asked in 1 Companies Intermediate   frequent | ||||
| ||||
Ans. Memory Leak is a situation wherein we have a reserved memory location but the program has lost its reference and hence has no way to access it. Java doesn't have concept of Pointers, Moreover Java has concept of Garbage collection that frees up space in heap that has lost its references. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  memory leak  garbage collection intermediate   frequent | ||||
| ||||
Ans. 1. Security and Safety - They can be shared across multiple threads as they are thread safe. Moreover, it protects then from bad state due to interception by the other code segment. One such problem due to mutability and access by alternate code segment could be the change of hash code and then the impact on its search with hash collections. 2. Reuse - In some cases they can be reused as only one copy would exist and hence it can be relied upon. For example - String Pool | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  immutable  immutability objects Asked in 1 Companies Intermediate   frequent | ||||