Monday, June 4, 2012

JAVA: Generics

Courtesy : http://java.sun.com/docs/books/tutorial/java/generics

public class Box {

    private T t; // T stands for "Type"          

    public void add(T t) {
        this.t = t;
    }

    public T get() {
        return t;
    }
}

During compilation, all generic information will be removed entirely, leaving only Box.class on the filesystem.

A declaration of Box, for example, would generate an error on the second occurrence of T, but Box, however, would be allowed.

The most commonly used type parameter names are:
  • E - Element (used extensively by the Java Collections Framework)
  • K - Key
  • N - Number
  • T - Type
  • V - Value
  • S,U,V etc. - 2nd, 3rd, 4th types

Static, when to use

Ever wondered when we see STATIC modifier in code, "what is it?". This article explains when to use it and beauty of it. A MUST go through for all who love to write aesthetic code.

http://www.codeproject.com/Articles/15269/Static-Keyword-Demystified

Summary: Declare methods or variables or properties as static when you think you don't need an object to access the corresponding. Static classes are different in different languages. In C# declaring a class to be static means that it contains only static members. So, recommendation is that write all generic and helper functions in a static class.

Friday, March 23, 2012

interview questions

Source: careercup

What happens when you type a URL into a browser?

1. Browser contacts DNS to resolve IP address
2.DNS replies back with the IP address of the site
3. Browser opens TCP connection to the server at port 80
4. Fetches index.html file from /home directory.!
5.Displays the content in browser
6.Stores the IP in DNS cache for future use.
7.When broswer closed, TCP conn is terminated..!!!

win7 usb/dvd download tool

win7 usb/dvd download tool is super sexy in making bootable dvd's and usb's. Awesome UI. Try it once and you will become a fan of it. Use the following link to download. http://www.microsoftstore.com/store/msstore/html/pbPage.Help_Win7_usbdvd_dwnTool. My next blog will be how to create a VHD and install win8 consumer preview on it. I am excited to finish that blog.

Friday, March 16, 2012

Some shortcuts

In cmd prompt u might have faced this issue many times. 1. You "cd" to a folder location. 2. Now you have to go to a folder location in different volume. 3. You "cd" to it. 4. Now, you have to go back to the previous folder. If I have to deal with these situations, I prefer using multiple cmd prompts. But that may turn out to be a hassle. This trick may help you out in those situations. >pushd . //pushes the current directory location into a stack. >popd //takes you back to that folder that is on the top of the stack Hope this helps. :)

SSD vs HDD

http://www.bing.com/videos/search?q=difference+between+ssd+and+hdd&view=detail&mid=DC8212ACD004D6E8054EDC8212ACD004D6E8054E&first=0 Very good read about difference between SSD and a HDD

MBR vs GPT

http://www.tomshardware.com/forum/233291-32-what-difference Good read about the differences between Master Boot Record and GUID Partition Table