Posts

Showing posts from September, 2020

Rest API Versioning

 Q How many ways to recommended to use common REST API versioning strategies : Ans : Versioning is a crucial part of API design. It gives developers the ability to improve their API without breaking the client’s applications when new updates are rolled out.   Four ways : 1  Versioning through URI Path http://www.example.com/api/ 1 /products 2. Versioning through query parameters http://www.example.com/api/products?version=1 3. Versioning through custom headers curl -H “Accepts-version: 1.0” http://www.example.com/api/products 4 Versioning through content negotiation curl -H "Accept: application/vnd.xm.device+json;   version=1 ”   http://www.example.com/api/products

How many ways to iterate in HashMap ?

Q How many ways to iterate in HashMap ? Ans : five ( 5) ways  package com.gsr.Map; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Map.Entry; public class IteratorWaysInMAP { public static void IteratorUsingEntrySet(Map<Integer,String> courseMap) { Iterator<Entry<Integer,String>> iterator=courseMap.entrySet().iterator(); System.out.println("Iterator Using EntrySet"); while(iterator.hasNext()) { Entry<Integer,String> entry=iterator.next(); System.out.println("Key is : "+entry.getKey()+"  and value is "+entry.getValue()); } } public static void IteratorUsingKeySet(Map<Integer,String> courseMap) { Iterator<Integer> iterator=courseMap.keySet().iterator(); System.out.println("Iterator Using KeySet"); while(iterator.hasNext()) { Integer key=iterator.next(); System.out.println("Key is : " +key+" and value is  "...