Interview Questions and Answers for 'Synchrony' - 3 question(s) found - Order By Rating Ans. Shutdown hook is a thread that is invoked implicitly by JVM just before the shut down. It is used to clean up unused resources. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 3 Companies Related Questions What are different ways to create String Object? Explain. Difference between JVM, JRE and JDK ? What are various types of Class loaders used by JVM ? Explain java.lang.OutOfMemoryError ? What are strong, soft, weak and phantom references in Java ? Which memory areas does instance and static variables use ? Can we call the garbage collector explicitly ? Why Java provides default constructor ? Can I import same package/class twice? Will the JVM load the package twice at runtime? Different types of memory used by JVM ? Basic and Very Frequently asked. Ans. Polymorphism means the condition of occurring in several different forms.
Polymorphism in Java is achieved in two manners
1. Static polymorphism is the polymorphic resolution identified at compile time and is achieved through function overloading whereas
2. Dynamic polymorphism is the polymorphic resolution identified at runtime and is achieved through method overriding. Sample Code for overloading Sample Code for overriding Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  polymorphism  object oriented programming (oops)  oops concepts  oops concepts Asked in 108 Companies Basic   frequent Try 2 Question(s) TestRelated Questions What are points to consider in terms of access modifier when we are overriding any method? If everything is an object , Cant we declare every object as
Object obj = new String(); Why do we need polymorphism in Java ? How does java identifies which method to be called in method overriding or runtime polymorphism, when both methods share the same name and signature ? Shouldn't we make a class with all static members is its just expected to be executed as a standalone program with just one thread. Moreover Lets assume that there is no runtime Polymorphism required and there is no need for serialization ? Is this Polymorphism ?
Map<String, List<String>> inventoryManagerCountMap = new HashMap<String, ArrayList<String>>(); When are static and instance methods resolved ? During compile time or Runtime ? Which of the following is not the difference between Singleton and Static class ( Class with static members only ) ? Which of the following do you think is the primary reason you would never use a static class even the application doesn't need multiple requests or threads ?
a. Serialization
b. Runtime Polymorphism
c. Lazy Loading
d. Memory Almost sure to be asked in every company using any Dependency Injection framework ( Spring, Guice etc ) Q3. What is Dependency Injection or IOC ( Inversion of Control ) ? Design
Ans. It is a Design Pattern that facilitates loose coupling by sending the dependency information ( object references of dependent object ) while building the state of the object. Objects are designed in a manner where they receive instances of the objects from other pieces of code, instead of constructing them internally and hence provide better flexibility. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  design patterns   ioc ( Inversion of Control )  dependency injection Asked in 83 Companies intermediate   frequent Related Questions What are the benefits of Dependency Injection or IOC ? What are different types of dependency injections ? Name few Dependency Injection frameworks ? Why do we need polymorphism in Java ? What are the various Auto Wiring types in Spring ? What is the difference betweeen @Inject and @Autowired ? Which of the following Java features facilitates Dependency Injection - Inheritance or Composition ? What are the different ways in which dependency injection can be done using Spring Framework ? Difference between constructor and setter injection ?