Thursday, 31 August 2017

What is Class Loader ? What are the Types (Hierarchy) of Java Class Loaders

Class Loader is used to load classes and interfaces.


Types of class loader


  • Bootstrap class loader : This class loader is responsible for loading core java API classes like rt.jar Bootstrap class loader is native implementation and so they may differ across different JVMs. Location :- jdk/jre/lib/rt.jar 

Simple Currency Formatter in Java

NumberFormat is the abstract base class for all number formats. This class provides the interface for formatting and parsing numbers. NumberFormat also provides methods for determining which locales have number formats, and what their names are.

NumberFormat helps you to format and parse numbers for any locale. Your code can be completely independent of the locale conventions for decimal points, thousands-separators, or even the particular decimal digits used, or whether the number format is even decimal.

Wednesday, 30 August 2017

Search String in Sorted String Array Using Binary search

Binary Search: Search a sorted array by repeatedly dividing the search interval in half. Begin with an interval covering the whole array. If the value of the search key is less than the item in the middle of the interval, narrow the interval to the lower half. Otherwise narrow it to the upper half. Repeatedly check until the value is found or the interval is empty.


We basically ignore half of the elements just after one comparison.

Wednesday, 23 August 2017

wrapper class in java

why we need wrapper class?

Java is an object oriented language and can view everything as an object. A simple file can be treated as an object, an address of a system can be seen as an object.

"wrapper can be used to convert any data type into object"

The primitive data types are not object they do not belongs to any class they are defined in the language itself that's why Java is not

Monday, 21 August 2017

public static void main (String args [] ) in Java

Main method in java is entry point for any core java program. Remember we are not talking about servlet, MIDlet or any other container based managed java program where life cycle method are provided to control the execution.

public static void main( String [] ar )

public - Java used this

Wednesday, 12 July 2017

Diffrence between @Controller and @ControllerAdvice in Spring Boot

@Controller 

  • @Controller is used to mark classes as Spring MVC Controller (e.g. a web controller).
  • It is typically used in combination with annotated handler methods based on the RequestMapping annotation.

@ExceptionHandler

@ExceptionHandler works at the Controller level and it is only active for that particular Controller, not globally for the entire application.

HandlerExceptionResolver

This will resolve any exception thrown by the application. It is used to resolve standard Spring exceptions to their corresponding HTTP Status Codes. It does not have control over the body of the response, means it does not set anything to the body of the Response.It does map the status code on the response but the body is null.

@ControllerAdvice

@ControllerAdvice used for global error handling in the Spring MVC application.It also has full control over the body of the response and the status code.

Monday, 29 May 2017

Basic Diffrence between Http and Https

Hyper Text Transfer Protocol Secure (HTTPS), which is the encrypted version of its predecessor HTTP. Both of these protocols are used to transfer data from a website's server to the browser on your computer, but when you try to connect to a website using HTTPS, your browser will first ask the web server to identify itself. Then the server will send its unique public key which is used by the browser to create and encrypt a session key. This session key is then sent back to the server which it decrypts with its private key. Now all data sent between the browser and server is encrypted for the remainder of the session.

For example, a government could tell that a user is browsing Wikipedia, but couldn't tell that the user is specifically reading the page about Tiananmen Square.

Wikipedia’s Switch to HTTPS Has Successfully Fought Government Censorship


Image: Wikimedia Commons/Shutterstock - Remix by Jason Koebler

Harvard researchers found fewer instances of Wikipedia censorship after the site started encrypting all of its traffic.

"Knowledge is power," as the old saying goes, so it's no surprise that Wikipedia—one of the largest repositories of general knowledge ever created—is a frequent target of government censorship around the world. In Turkey, Wikipedia articles about female genitals have been banned; Russia has censored articles about weed; in the UK, articles about German metal bands have been blocked; in China,

Sunday, 28 May 2017

Render web page to Image using phantom js

Install phantomjs
$ npm install phantomjs
Create a file github.js with following code
var page = require('webpage').create();
//viewportSize being the actual size of the headless browser
page.viewportSize = { width: 1024, height: 768 };
page.open('http://github.com/', function() {
    page.render('github.png');
    phantom.exit();
});
Pass the file as argument to phantomjs
$ phantomjs github.js
Happy Coding !!
By: saurabh saxena

The Race for Self-Driving Cars

Autonomous cars have arrived. Major automakers have been investing billions in development, while tech players like Uber and Google’s parent company have been
testing their versions in American cities.


How a Car Drives Itself


LIDAR UNIT
CAMERAS
Constantly spinning, it uses laser beams to generate a 360-degree image of the car’s surroundings.
Uses parallax from multiple 
images to find the distance to 
various objects. Cameras also 
detect traffic lights and signs, 
and help recognize moving
objects like pedestrians and 
bicyclists.

RADAR SENSORS
Measure the distance from the car to obstacles.

MAIN COMPUTER
(LOCATED IN TRUNK)
ADDITIONAL
LIDAR UNITS
Analyzes data from the sensors, and compares its stored maps to assess current conditions.
By Guilbert Gates |Source: Google | Note: Car is a Lexus model modified by Google.