Friday, September 17, 2010

Can somebody explain this?

It was when I was going through a book 'Women - A primer for Men' that I encountered these lines. Can some body please explain what it means?


“Women ask men impossible to answer questions because the question we actually asked is not he question we really want answered. You only have to lie if you answer the question we actually asked rather than the one we really want answered. You would not have to lie if you ignored the question we actually asked and answered the question we really wanted answered. This is specially true if the question we actually asked requires the man to give an opinion in his answer which is never permitted. (If a man gives a woman his opinion on any topic he should immediately apologize and humbly beg her forgiveness unless said opinion deals directly with automobiles or power tools.) Be advised that women ask these questions as a test. We are determining your ability to read subtext, deciding whether to continue the relationship or not, and seeing how clever you really are as shown by the quality of your answer. You will remember that women are naturally more sibylline than men and that we enjoy playing that delightful game "Confuse-A-Male". This has been a test. This has only been a test. If this had been an actual emergency requiring an opinion we would have
asked a woman.” 




He has also written 'Men - A primer for Women' but has not written anything of this sort for men. I wonder why and so do all the existing women on the earth. May be because he is a man. :)

Saturday, February 20, 2010

Test Your GK

Here are a few interesting questions you must know. Answer them and see how many you knew :

1) Do identical twins have same finger prints ?
2) Who wrote our National Song, Vande Matram?
3) 'Bluetooth' technology is named after whom?
4) If you search for something in google and you get just one result, then what is it called?
5) What is the full form of SMS?
6) What is the full form of MMS? I know you know this ;)
7) How many legs do butterflies have?
8) What do you call a group of sheep?
14)Which is the best selling car name of all time?
15)Which is the only vowel on a standard keyboard that is not on the top line of letters?
16)Which metal is liquid at room temperature?
17)Pencil lead is made of?
18)What does the acronym RTOS stand for?
19)In which organ of the body the pineal gland?
20)In which year was Mahatma Gandhi assassinated?


Answers : 

1) No
2) Bankim Chandra Chaterjee
3) Harold Bluetooth-2, Viking King of 9th Century 
4) Google Whacking
5) Short Message Service
6) Mutimedia Messaging Service
7) 6
8) A Flock of Sheep
9) Big Apple
10)Thailand
11)Five
12)Intelligent. hahahaha..this is funny!
13)UK
14)Toyota Corolla
15)A
16)Mercury
17)Graphite
18)Real Time Operating System
19)Brain
20)1948

Friday, February 19, 2010

What is Extreme Programming (XP)?

Extreme Programming is a popular practice towards software development. It is a light weight, flexible, tested, predictable and hence low risk way to develop a software. It is one of the many Agile Processes. Extreme Programming was created by Kent Beck. The first Extreme Programming project was started in 1996.

Here are a few basics about Extreme Programming :

  • XP enables you to respond to changing customer requirements, even late in the life cycle.Like all agile processes, it has very short cycles which lets you take early and continuing feedback from the customer.
  • XP is ideal to be used in a scenario where the customer's requirements keep on changing.
  • Coding, code review and unit testing of the code are done simultaneously in this practice.
  • XP needs frequent communication with the customer.
  • We need to deliver working software frequently from a couple of weeks to a couple of months

Usage of Extreme Programming ensures customer satisfaction.

What is Vaccination?

How many of us do actually know that Vaccinations are nothing else but the same disease causing antigens for which you are being given the vaccination? Yes, this is true.

For example, Hepatitis is caused by HPV (Hepatitis B Virus) and the vaccination for hepatitis actually contains HBV in dead or weakened forms. This is done to make your body ready for fighting the disease when these antigens actually attack on you in large/severe amounts.

We have two kinds of cells in our body which are used to fight diseases: B cells and T cells. Whenever an antigen attacks our body for the first time, these cells create a code to fight those antigens. Once the code is created, next time the antigen attacks, these cells are able to fight the antigen very fast as they already have the code created for that specific antigen.

Hence, we are given antigens in the form of vaccinations so that the code for fighting them is created in our body and when they attack in large amounts later in our lives, our body can fight them back fastly.

Java Ring.. do you know it?

Java...java..java...its everywhere and we think..'Ahh, I know java'. I bet, you do. But do yo know what is JAVA RING?

I know, you don't. Let's see what this Java Ring is all about.

Java Ring is a ring you can wear and which is actually a computer. It contains 6 kilobytes of RAM. Its a microcomputer with a powerful JVM. It was introduced by Sun Microsystem in 1998. It was built by Dallas Semiconductor.



Uses : You can use  Java Ring to store your credit card numbers, passwords, secret code, telephone numbers etc. It can also be used as an access card.

Thursday, February 18, 2010

What is Multithreading?


If two or more threads can run through your program concurrently, then that is known as multi threading:
  • Advantages : Multithreading can make the execution faster by making use of the unused resources by one thread at some point of time.
  • Disadvantages : Concurrent execution of multiple threads can lead to delay in the completion of individual thread due to sharing of resources.
Improper use of multithreading can lead to corrupted data. To avoid this, we can use synchronization. Synchronization is used to ensure that only one thread executes in a critical region at a time. Critical Regions are places where modification in the data is done. Ideally, only one thread should be executing in the critical regions.
Synchronization can be achieved by two ways:
  • Synchronized blocks:  We use synchronized blocks when we intend only a few lines of code to be synchronized.
class myClass {
    myMethod() {
      synchronized (object) {
         statement block
      }
   }
}
In this case, the object specified in the statement is the lock.
  • Synchronized methods : We use synchronized methods when we want the complete method to be synchronized.
class myClass {
   synchronized type myMethod() {
      statement block
   }
}
In this case, lock is obtained on the object being referenced in the synchronized method. Two synchronized methods referring to the same object can not be called simultaneously from two different threads.

Deadlock :  When two or more threads are waiting for each other to release some resource, they are unable to proceed with their own executions and keep on waiting. This condition is known as deadlock.
Deadlock can also include more than two threads. This happens when more than two thread are waiting for another thread to release the lock over a resource. See an example below:
Thread 1 waits for Resource A locked by Thread 2
Thread 2 waits for Resource B locked by Thread 3
Thread 3 waits for Resource C locked by Thread 1

Wednesday, February 17, 2010

Best java Interview Questions faced by me:

How to get classpath from java code?
Ans : System.getProperty(“java.class.path”);

2) How to write methods in JSP code?
Ans : We can write jsp methods in tag. This part of the code is compiled and inserted outside the _jspservice() method in the generated servlet class.

3) If your design changes frequently, what would you prefer to use: interfaces or abstract classes?


4) If an object of a class is being used as the key of a Map, what methods should it compulsorily implement?
Ans : It should implement the equals and hashcode method

5) What is a String Pool?

6) How to increase the memory of JVM? Not specific to tomcat apache. Specific to java.

7) How to know if an object is an object of a serializable class?

8) How does driver manager get loaded?

9) Can a static method be overridden?

10) Can we override service() method in jsp?
Ans: No, we can not.

There is more to come ...

Introduction to Maven Repositories

A maven repository is a repository where files and artifacts of different types can be stored and can be shared by any number of builds.
Maven repositories can be classified into two: Local and Remote.
Local Repository: This is the one which is on your own installation. It might contain temporary build artifacts which are yet to be released. One can make the changes and test them at its local repository before making the release.
Remote Repository: This is the one which is setup by a third party and can be shared by many for downloading at the local repository.
Commands Used:
For cleaning your local repository, use mvn clean or mvn –o clean.
For building your repository, use mvn install or mvn –o install.
Note : ‘-o’ is used when you intend to do the clean/ build offline.
You can also write your command as mvn –o clean install.

You can also append
--> --> -->-DSkipTestCases = true to your
command to skip the test cases to be executed. This could make your build faster.
Setting up a maven project :


  •      Go to File -- > Import

  •     Select ‘Maven Projects’ under ‘General’ in the pop up window and click on next.


  •      Browse the Root Directory and click on OK.




  •      The directory selected should have a valid pom.xml


  •  Click on Finish.
     It will import your project now and then you are good to go.




What is Febrile Seizure

My son suffered from febrile seizure attack when he was 18 months old. It was scary, but then I did complete research on febrile seizure. Now, I know that it is a common but an unknown thing for many. Parents of kids, who have suffered febrile seizures, should keep the following things in mind:

1) Febrile seizures are caused by sudden increase in the body temperature. So always keep crocin/paracetamol (any fever controlling medicine) handy and give this to your kid whenever you see the temperature rising. This has to be done as soon as possible to avoid his temperature from rising very high.

2) Visit to the doctor as soon as the temperature lowers.

3) Do not ever take your kid to the doctor while he is having the attack. Let him come back to the normal state and then take him to the doctor.

4) Let the air pass freely around you kid while he is under the seizure. Loosen all his clothes around the neck and waist.

5) Do not try to move him when he is under the seizure. Just make him lie on a flat surface.

6) In case the seizure lasts for more than 5 minutes or your kid turns blue, immediately call the doctor.

7) Keep an eye on the watch to notice the duration of seizure for further treatment.

8) Kids outgrow the possibility of febrile seizure attacks when they are five years older or more.

9) Only half of the kids who have suffered the attack, suffer it for the second time.

10) Only one third of the kids who have suffered the febrile seizure attack twice, suffer it for the third time.

11) Febrile seizure attacks after three times are very rare.

How to make a class singleton?

I have been wondering about the ways a class can be made singleton. One way I know of is to make the constructor of the class private. Add another method in the class which would first check if an instance of the class exists or not. In case it exists, it returns the same instance else creates a new instance.


public class MyClass {

         private static MyClass myClassInstance;

         public static MyClass getInstance()
        {
             if(null== myClassInstance )
            {
                   myClassInstance = new MyClass ();
            }
           return myClassInstance ;
        }

        private MyClass () {
        }

}


Guys, Please share if you know any other way of making a class singleton.