GeekInterview
  Menu  
 Search 
  • Showing 1 - 5 of 5 Ans
  • Prasad MN

    Answered On : Mar 19th, 2013

  • The main difference of creation of hashmp instance

    HashMap hm = new HashMap(); Here we are getting the HashMap methods only will get inherited.

    Where as
    Map mp= new HashMap(); // Here will get the Map interface methods inherited into class.

  • sahil

    Answered On : May 30th, 2014

  • Hi Prasad,

    Sorry to say but this cannot be the correct answer.
    HashMap class inherits the map interface, so it must be having all the methods from map interface.
    Please read your answer after reading mine. You will get to know the concept.

  • Pulkit

    Answered On : Jan 6th, 2015

  • Using the Map mp = new HashMap() convention we can convert one collection into a different collection implementation. Thus if there are two classes which implementation for Map interface you can at runtime change the collection type. This is the preferred way for creating collections as per the Oracle recommendation.

  • Ganesh Bhat

    Answered On : Apr 3rd, 2015

  • Map m = new HashMap(); here the reference of interface Map holds the object of HashMap, this is called Liscov Substitution Principle. OO Principles encourages to write implementation to interfaces than to implementations. Thereby you can easily switch the implementations without affecting rest of your module.

    This concept introduces Cold Spot and HotSpot in the design, HotSpot is place in your design, which allows you to change, cold is one frozen.

  • Thomas John

    Answered On : Sep 22nd, 2015

  • Command decouples the object that invokes the operation from the one that knows how to perform it. To achieve this separation, the designer creates an abstract base class that maps a receiver (an object) with an action (a pointer to a member function). The base class contains an execute() method that simply calls the action on the receiver.

    An example can be seen when we go to a restruant and order food. The waiter takes the order and passes it to the kitchen. A cook in the kitchen will take the order and prepare the order. Here the customer is the object that invokes the operation, order is the command interface/abstract class and the cook is class that implements the command interface.

  • Answer Question
  • Click here to Login / Register your free account

    Image Verification :

Copyright © 2022 GeekInterview.com | All Rights Reserved