Sunday, 10 December 2023

Java Development Frameworks

 

Spring Boot :- A Java framework for creating microservices and Spring-based applications. It provides a number of features that make it easy to develop and deploy applications, including auto-configuration, starter dependencies, and embedded web servers.

Hibernate :- An object-relational mapping (ORM) framework that provides a way to map Java objects to database tables. It makes it easy to persist and retrieve Java objects from the database.

Struts :- A web application framework that provides a number of features for developing web applications, including a model-view-controller (MVC) architecture, validation, and internationalization.

Play :- A web application framework that provides a number of features for developing web applications, including a routing system, an action controller, and a view system.

Grails :- A web application framework that provides a number of features for developing web applications, including a convention over configuration (COnC) approach, a domain-specific language (DSL), and a plugin system.

JavaServer Faces (JSF):- A web application framework that provides a number of features for developing web applications, including a component-based architecture, a state management system, and a validation system.

Dropwizard :- A web application framework that provides a number of features for developing web applications, including a convention over configuration (COnC) approach, a builder API, and a health check system.

Saturday, 9 December 2023

50 Ways To Save Money At The Airport

 Today I read a good article on 50 Ways To Save Money At The Airport



More details are here :- It worth spending 10 mins are reading it

Click here to know the details :- 50 ways to save money at airport



Saturday, 6 July 2019

SDET Interview Questions




Microservice  Service Contract


A microservice will have a service contract associated with it. The same way that a supplier of yours will sign a contract with your company assuring certain response times, how they can be contacted and exactly what services they provide  the same can be said for a microservice.
    • MyMicroservice will always respond to a request within x milliseconds.
    • MyMicroService will always respond to a request on port XYZ
    • MyMicroService will accept a request of Type A and perform Action B.
Above is the defined service contract for My Microservice. You know what you are getting. You know that you can rely on it. And you know exactly what it will do  when you ask something of it.

Wednesday, 13 December 2017

Difference between Reference and Object



Lets assume that we have a class called Employee in Java. This is how you would create a reference of the Employee class:


Create a reference
Employee e;

Now if you wanted to create an instance or object of the Employee class, you would do so:

Create an reference and an object
Employee e = new Employee();

This gives a direct answer to your question, but to understand the real difference between references and objects, you need to understand a little about how memory is managed in Java

In java, all types are divided into two categories,  primitive types which include int, long, char, boolean and so on, and reference types like String, Date, BufferedReader and other classes. This difference is based on the manner in which memory is allocated to the variables of these types. For example,

int b;
int a = 10;

Both these statements cause the same effect, memory wise. A block of memory from the stack, big enough to hold an int (4 bytes) is allocated to these variables. This memory is allocated statically, since the size of int and other primitive types is fixed. (The ??? in the diagram indicate some unknown value since the integer has not been initialized yet)

Consider the employee class.

Employee e;
Employee emp = new Employee();

These two statements have different effect memory-wise since they are reference types. The first statement just creates a reference, or a pointer if you will, to an instance of type Employee. This essentially means, the statement tells the compiler "e" is going to point (refer) to an Employee object, but right now is pointing to nothing (null). The interesting part is, the reference itself, that is "e" is stored on the stack statically. So, here you create just the reference.

The second statement however, does more than this. "emp" is allotted memory as a reference as in the previous case, but the use of new keyword creates an object and allots memory to it on the heap, at runtime, i.e dynamically. This statement tells the compiler "emp" is going to refer to the  Employee object that will be created as a result of the new keyword. So, here you create a reference and an object that the reference variable refers to.



what happens when you type in a URL in browser


In an extremely rough and simplified sketch, assuming the simplest possible HTTP request, no proxies, IPv4 and no problems in any step:
  1. browser checks cache; if requested object is in cache and is fresh, skip to #9
  2. browser asks OS for server's IP address
  3. OS makes a DNS lookup and replies the IP address to the browser
  4. browser opens a TCP connection to server (this step is much more complex with HTTPS)
  5. browser sends the HTTP request through TCP connection
  6. browser receives HTTP response and may close the TCP connection, or reuse it for another request
  7. browser checks if the response is a redirect or a conditional response (3xx result status codes), authorization request (401), error (4xx and 5xx), etc.; these are handled differently from normal responses (2xx)
  8. if cacheable, response is stored in cache
  9. browser decodes response (e.g. if it's gzipped)
  10. browser determines what to do with response (e.g. is it a HTML page, is it an image, is it a sound clip?)
  11. browser renders response, or offers a download dialog for unrecognized types
Again, discussion of each of these points have filled countless pages; take this only as a short summary. Also, there are many other things happening in parallel to this (processing typed-in address, speculative prefetching, adding page to browser history, displaying progress to user, notifying plugins and extensions, rendering the page while it's downloading, pipelining, connection tracking for keep-alive, checking for malicious content etc.) - and the whole operation gets an order of magnitude more complex with HTTPS (certificates and ciphers and pinning, oh my!).




The Transmission Control Protocol (TCP) is one of the main protocols of the Internet protocol suite. It originated in the initial network implementation in which it complemented the Internet Protocol (IP). Therefore, the entire suite is commonly referred to as TCP/IP. TCP provides reliable, ordered, and error-checked delivery of a stream of octets between applications running on hosts communicating by an IP network. Major Internet applications such as the World Wide Webemailremote administration, and file transfer rely on TCP. Applications that do not require reliable data stream service may use the User Datagram Protocol (UDP), which provides a connectionless datagram service that emphasizes reduced latency over reliability.

Get the Number of Duplicate Elements in the List or Array

public class NoOfDuplicateElementsInTheList {

public static void main(String[] args) {
// TODO Auto-generated method stub
String[] arr = {"cat","dog","cow","cat","dog","mice"};
Map<String,Integer> mp= new HashMap<String,Integer>();
for(int i=0;i<arr.length;i++){
if(mp.containsKey(arr[i])){
mp.put(arr[i], mp.get(arr[i])+1) ;
}else{
mp.put(arr[i], 1);
}
}
for(Entry<String,Integer> e : mp.entrySet()){
System.out.println(e.getKey() +"-"+e.getValue());
}

}


}