Tuesday 28 August 2012

Important Books and their Authors for general awareness exams - Part 1


Ain-e-Akbari - Abul Fazal
Alice in Wonderland - Lewis Carrol
Arthashastra - Kautilya
Abhijnan Shakuntalam - Kalidas
Agni Veena - Kazi Nazurul Islam
Agni Pariksha - Acharya Tulsi
A passage to India - E.M. Forster
Bharat Bharati - Maithili Saran Gupta
Charitraheen - Sarat Chandra Chatterjee
Discovery of India - Jawahar Lal Nehru
Death of a city - Amrita Pritam
Das Capital - Karl Marx
Descent of Man - Charles Darwin
Devi-The Bandit Queen - Richard Shears and Isoble Gidli
Death, The Supreme Friend - Kaka Saheb Kalelkar
Experiments with Untruth - Michael Anderson
Eternal India - Mrs Indira Gandhi
Glimpses of World History - Jawahar Lal Nehru
Glimpses of India - Humayun Kabir
Gitanjali - Rabindra Nath Tagore
Harsha Charit - Bana Bhatta
Hindu View of Life - Dr. S Radhakrishnan
India Wins Freedom - Abul Kalam Azad
Indian Philosophy - Dr. S Radhakrishnan
I Follow the Mahatma - K. M. Munshi
Jobs for Millions - V.V Giri
Kamayani, Prem Pathic, Ajatshatru - Jai Shanker Prasad
Mahabarat - Veda Vyas
Mein Kempf - Hitler
My Childhood Days - Taslima Nasreen
My days - R. K. Narayan
My Experiments with Truth - Mahatma Gandhi
My Music My life - Pt. Ravi Shankar
My Presidential Years - R. Venkataraman

Now follow: Important Books and their Authors for general awareness exams - Part 2

You may also like:

Which cups and trophies are for what sport (India And World)




Saturday 25 August 2012

Which cups and trophies are for what sport (India And World)


These are really important to learn if you are going to face any general awareness or general knowledge exam. The cups and trophies are mostly asked in exams like SSC, Intelligence Bureau, AFCAT and other private and government sector exams. So I am providing you with some really important cups and trophies and the sport to which they belong.


Agha Khan Cup - Hockey
Lady Ratan Tata Trophy - Hockey ( Women , India )
Rangaswami Cup - National Hockey Championship India
Rene Frank Cup - Hockey ( India )

Durand Cup - Football ( India )
I.F.A Shield - Football
Jules Rimet Trophy - Football ( World )
Rovers Cup - Football
Santosh Trophy - National Football ( India )

Duleep Trophy - Cricket ( India )
Ranji Trophy - Cricket ( India )
Rohinton Baria Trophy - Cricket ( Inter-university )

Barna Bellack Cup - Table Tennis ( Men )
Swaythling Cup - World Table tennis ( Men )

Davis Cup - Lawn Tennis ( International )
Wightman Cup - Lawn Tennis ( England )
Wimbledon Trophy - Lawn Tennis ( England )

Thomas Cup - World Badminton ( Men )

Ezra Cup - Polo

Walker Cup - Golf

Hope you liked this information. 
Please like this page if you found it helpful and do share it.

The other important general awareness topics are :

National parks and wildlife Sanctuaries - Which is in which state?
Famous inventions and discoveries.



Monday 20 August 2012

Famous Inventions and Discoveries



Invention/Discovery - Discoverer/Inventor

America  - Christopher Columbus
Solar System - Copernicus
North Pole (Explored) - Robert Peary
South Pole (Explored) - Amundsen

Dynamite - Alfred Nobel
Electron - J.J. Thomson
Incandescent Bulb - Edison
Law of Gravitation - Newton
Printing for the Blind - Louis Braille
Radium - Madame Curie
Theory of Relativity - Albert Einstein
Telegraph - Samuel Morse
Theory of Evolution - Charles Darwin
Telephone - Graham Bell
Radio - Marconi
X-Ray - W. K. Roentgen

Aeroplane - Wright brothers (William & Oliver Wright)
Bicycle - Macmillan
Dynamo - Michael Faraday
Diesel - Rudolf Diesel
Fountain Pen - Waterman
Gramophone - Edison
Helicopter - Etienne Ochmichen
Microscope - Z. Jansen
Motorcycle - G. Daimler
Printing Press - Gutenberg
Pneumatic Tyres - Dunlop
Revolver - Colt
Submarine - David Bushnell
Thermometer - Fahrenheit
Transistor - W. Shockley
Typewriter - Sholes
Television - J.L. Baird
Telescope - Hans Lippershey 

These are some really important inventions always asked in various exams.

Related topics



                                                        

National parks and Wildlife sanctuaries of India. Which national park is in which state ?


National Parks :

Corbett National Park             --              Nanital, Uttarakhand

Kaziranga National Park          --             Jorhat, Assam

Gir National park                    --             Rajkot, Junagadh, Gujarat

Ranthambose National Park    --             Rajasthan

Kanha National Park               --              Madhya Pradesh

Dudhwa national Park             --              Uttar pradesh

Guindy National Park             --              Chennai, Tamil Nadu

Nagarhole National Park         --              Karnataka

Bandipur National Park          --              Karnataka

Periyar National Park             --              Kerala 



National Wildlife Sanctuaries :

Dachigam Wildlife Sanctuary             --                Jammu & Kashmir

Sariska                                                --                 Rajasthan

Hazaribagh Wildlife Sanctuary           --                 Jharkhand

Tiger Project                                        --                 Rajasthan

Mudhumalai Wildlife sanctuary          --                 Tamil Nadu

Periyar Wildlife Sanctuary                 --                 Kerala

National Chambal (Gharial)             --       Etawah,  Uttar Pradesh 

Wildlife Sanctuary



These are mostly asked in any general awareness exam like PCS, SSC, AFCAT etc. So learn these as soon as possible if you are preparing for these exams.

Some other important things to learn will be provided in my other articles.

You may also like :

Interesting full forms

Famous inventions and discoveries


Sunday 19 August 2012

What is a abstract class in java ?



There are situations in which we want to define a superclass that declares a structure of a given abstraction without providing a complete implementation of every method, i.e sometimes we want to create a superclass that only defines a generalised form that will be shared by all of its subclasses leaving it to each subclass to fill in the details. Any class that contains one or more abstract methods must also be declared abstract. To declare a class abstract we simply use the abstract keyword infront of the class keyword in the beginning of class declaration.
There can be no objects of an abstract class, i.e an abstract class cannot be directly instantiated with the new operator. Also you cannot declare abstract constructors or abstract stating methods. Any subclass of an abstract class must either implement all of the abstract methods in the superclass or be itself declared abstract.

For example :

abstract class A
{
        abstract void callme( );                  //abstract method that will 
                                                             //be defined in sub class
        void callmetoo( )
         {
              System.out.println(" This is a concrete method ") ;
          }
}

class B extends A
{
          void callme( )            //defination of abstract method
                                            // of super class
           {    
                 System.out.println("Implentation of callme in B");
            }
}

class C extends A
{
          void callme( )
          {
                 System.out.println("Implentation of callme in C");
           }
}
class AbstractDemo

            public static void main( String args [ ] )
            {
                   B b = new B( );
                   C c = new C( );
                   b.callme( );
                   b.callmetoo( );
                   c.callme( );
                   c.callmetoo( );
              }
 }



hence output of the above program will be:

Implentation of callme in B
This is a concrete method
Implentation of callme in C
This is a concrete method

Friday 17 August 2012

Multithreading - Creation of a thread by Runnable interface


The easiest way to create a thread is to create a class that implements the runnable interface. You can construct a thread on any object that implements runnable. To implement runnable , a class need only implement a single method called run( ).
Run( ) establishes the entry point for another concurrent thread of execution within your program. This thread will end when run( ) ends.


For example:

class NewThread implements Runnable
{
       Thread t;
       NewThread( )
       {
               t = new Thread (this,"DemoThread");
               System.out.println("child thread :" +t);
               t.start( );
        }
        public void run( )
       {
              try
              {      
                     for(int i=5; i < 0; i--)
                     {
                           System.out.println("child thread" +i );
                           Thread.sleep(500);
                      }
                }
                catch( InterruptedException e )
                {
                       system.out.println(" child interrupted" );
                 }
                 System.out.println(" child thread exiting")
          }
    }

class ThreadDemo
{
         public static void main( String args[ ] )
         {
               new NewThread( );
               try
               {
                      for(int i=5; i > 0; i--)
                      {
                              System.out.println (" main thread" +i );
                               Thread.sleep(1000);
                      }
                }
                catch ( InterruptedException e )
                {
                       System.out.println (" Main thread interrupted ");
                 }
                 System.out.println( " main thread exiting ") ;
           }
}



Multithreading - Creating thread by extending a thread class


Before starting this, you must know what is mulithreading.


A thread is to create a new class that extends thread and then to create an instance of that class. The extending class must override the run method which is the entry point for new thread. It must also call start( ) to begin execution of the new thread.

Creating a thread :

class NewThread extends Thread
{
      NewThread( )
      {
              super("Demo Thread");   //will call the 
                                                      //constructor of super class thread     
              System.out.println(" child thread: " +this);
              Start( );
      }
      public void run( )
      {
              try
              {
                     for(int i=5; i > 0; i--)
                     {
                           System.out.println(" child thread "+i );
                           Thread.sleep(500);
                     }
              }
              catch(InterruptedException e)
              {
                           System.out.println("child interrupted");
               }
              
               System.out.println("exiting child thread");
       }
}

class ExtendThread
{            
            public static void main( String args[ ])
            {
                    new NewThread( );
                    try
                    {
                            for(int i=5; i >0; i--)
                            {
                                 System.out.println("main thread" +i );
                                 Thread.sleep(1000);
                            }
                   }
                   catch( InterruptedException e)
                   {
                           System.out.println(" main interrupted");
                    }
                    System.out.println(" main thread exiting");

             }
}



output:
child thread: Thread[ DemoThread, 5, main]
main thread: 5
child thread: 5
child thread: 4
main thread: 4
child thread: 3
child thread: 2
main thread: 3
child thread: 1
exiting child thread
main thread: 2
main thread: 1
main thread exiting



Related topics:
what is multithreading
creating thread by runnable interface













What is multithreading in Java ?

A multithreading program contains two or more parts that can run concurrently. Each part of such a program   is called a thread and each thread defines a seperate path of execution. Thus multithreading is a specialized form of multitasking.

However there are two distinct types of multitasking :
1. Process based       
2. Thread based

It is important to understand the difference between these two : 
Process based multitasking is the feature that allows your compiler to run two or more programs concurrently. Example. Process based multitasking enables you to run the Java compiler at the same time when you are using a text editor.
In thread based multitasking, a single program can perform two or more tasks simultaneously.

Thread Priorities :
Java assigns to each thread a priority that determines how that thread should be treated with respect to the others. A thread priority is used to decide when to switch from one running thread to the next. This is called the context switch.
  •  A thread can voluntarily relinquish control. This is done by explicitly locking or sleeping on pending input output. In this scenario all other threads are examined and the highest priority thread that is ready to run is given the CPU.
  • A thread can be preemted by a higher priority thread.

Java defines two ways of creating a thread :
  1. You can implement runnable interface .
  2. You can extend the thread class itself.

Now follow :


Wednesday 15 August 2012

Uses of keyword final in JAVA



Keyword " final " has three uses :

Use 1 : A variable can be declared as final, doing so prevents its contents from being modified. This means that we must initialize a final variable when it is declared.
For ex :
Final int a = 2 ;


The next two uses of Final apply to inheritance. 


Use 2Using Final to prevent overriding

While method overriding is one of the Java's most powerful feature, there will be times when we want to prevent it from occurring, to disallow a method from being overridden specify Final as a modifier at the start of its declaration.
Methods declared as final cannot be overridden.

class A
{      Final void math( )
        {
              System.out.println("This is a final method");
         }
}
class B extends A
{        void math( )         //illegal
          {       
                System.out.println("illegal"); 
           }
}



Use 3 : Using Final to prevent inheritance

Sometimes we want to prevent a class from being inherited. To do this precede the class declaration with final. Declaring a class as final implicitly declares all of its methods as final too.
As we expect it is illegal to declare a class as both abstract and final since an abstract class is incomplete by itself and relies upon its subclasses to provide complete implementations.

final class A
{    ......
      ........
      ........
}
class B extends A                    // illegal

}



Hope this helped.....

Use of keyword super in JAVA



The keyword super has two general forms :

The first calls the constructor of the super class.
The second is used access a member of the super class that has been hidden by member of a sub class.

First use of super

class Box
{    double width;
      double height;
      double depth;
      Box(double w, double h, double d)            //constructor
         {       width = w ;
               height = h ;
               depth = d ;
          }
      double volume( )
        {         return width*height*depth;
       }

 class Boxweight extends Box
 {       
        double weight;
        Boxweight( double w, double h, double d, double m)
        {
                   super(w, h, d);    //This will call the constructor of  
                                               //super class Box
                   weight = m;
         }
  }



Second use of super

This 2nd form of super is most applicable to situations in which member names of a subclass hide members by the same name in the   
super class.

class A
{      int i;
}

class B extends A
{      int i;
        B( int a, int b)
        {     super.i = a;
               i = b;
         }
         void show ( )
         {     
                 System.out.println(" i in superclass : " +super.i  );       
                                                                           //will
                                                                           // print the value of i
                                                                           // of super class A 
                 System.out.println(" i in subclass : " +i )  ;
          }
  }

class UseSuper

          public static void main( String args[] )
          {
                  B Subob = new B(1,2);
                  Subob.show( );
           }
 }

       
Hence the output of the above program will be:

i in superclass : 1
i in subclass : 2



please ask if there are any queries....

Tuesday 14 August 2012

Interesting Full forms of various Brands and other things. Often asked in General knowledge in PCS and other exams.



Expansion of :


ADIDAS - All Day I Dream About Sports
( However its named after the founder Adolph Dassler from his nikname, Adi for Adolph and Das for Dassler. But still this is the commonly known full form of Adidas)


FILA - Finally I Left Adidas
( Its said that the Founder of Fila first worked with adidas but when he left adidas, he started this company)


NIKE - Greek goddess of victory


KISS - Keep It Short and Simple
(In mode of communication)


LG - Life's Good (in general)
( But its " Lucky Goldstar " as the company was started in 1947 as lucky goldstar and in 1950 it abbreviated its name to LG)


KFC - Kentucky Fried Chicken


LOVE - Long Original Valuable Emotion
( Different people interpret the word in different ways but this is the most common full form)

ICICI -  Industrial Credit And Investment Corporation Of India.


BMW Bayerische Motoren Werke (in German) and Bavarian Motor Works (in English)



Also have a look at full forms of famous companies.

Friday 10 August 2012

Important questions in technical interview of Java.



Here I am providing the most important questions that are mostly asked in any technical interview of Java :

1. (If you have also mentioned C and C++ in your resume)
     What is the difference between C, C++ and Java ?


2. Explain OOPs concepts with example.


3. What is the difference between method overloading and method overriding?


4. What is runtime and compile time polymorphism ? Explain with example.

5.  Difference between String and StringBuffer class ?

6.  Multithreading and runnable interface.

7.  Meaning of public, static, void in " public static void main( String args[]) " 


8. What is a constructor?


9. What is the use of keyword super in Java?


10. What is the use of keyword final in Java?




Will provide some more interview questions and answers in my future updates.........

Till then practice these...........

Good Luck.........

Parameterized constructors


class Box
    {    double width;
          double height;
          double depth;

          Box( double w, double h, double d)
          {    System.out.println("constructing box");
                width=w;
                height=h;
                depth=d;
         }

         double volume( )
         {       
                   return width*height*depth;
         }
     }
class BoxDemo
     {
               public static void main( String args[])
               {    Box mybox1=new Box(10,20,15);
                     Box mybox2=new Box(3,6,9);
                     double vol;
                     vol=mybox1.volume( );
                     System.out.println("Volume of first box is"+vol);
                     vol=mybox2.volume( );
                     System.out.println("Volume of second box is"+vol);
                 }
      }


In a parameterised constructor the parameters are passed while creating a object as done here:
Box mybox1=new Box(10,20,15);
The values 10,20 and 15 are passed to the constructor of class box and width, height and depth of box 1 will be initialized to these values.
Similarly we are passing values 3,6 and 9 for box 2, hence its width,height and depth are initialized to 3, 6 and 9.

hence the output of above program will be:

Volume of first box is3000
Volume of second box is162            




To know about unparameterized constructors click here

What is a constructor in Java?



It can be tedious to initialize all of the variables in a class each time an instance is created. JAVA allows objects to initialize themselves when they are created. This automatic initialization is performed through the use of constructor.
A constructor initializes an object immediately upon creation. It has the same name as the class in which it resides and is syntactically similar to a method. Once defined it is automatically called immediately after the object is created before the new operator completes.
Constructor have no return type not even void. This is because the implicit return type of a constructor is the class type itself.

For example:

class Box
    {    double width;
          double height;
          double depth;

          Box()
          {    System.out.println("constructing box");
                width=10;
                height=10;
                depth=10;
         }

         double volume( )
         {      
                   return width*height*depth;
         }
     }
class BoxDemo
     {
               public static void main( String args[])
               {    Box mybox1=new Box( );
                     Box mybox2=new Box( );
                     double vol;
                     vol=mybox1.volume( );
                     System.out.println("Volume of first box is"+vol);
                     vol=mybox2.volume( );
                     System.out.println("Volume of second box is"+vol);
                 }
      }


the output of this program will be :   (How to compile and run a program)

Volume of first box is1000
Volume of second box is1000



* In order to pass different parameters to both boxes we have to use Parameterized constructor.





Thursday 9 August 2012

Tired of searching job ?



Searching for job is one of the most toughest task. Its quite hectic to go and search for job in the market and return empty handed in the evening. But this does not mean that you lose your confidence, keep trying.
Success comes to everyone in the end, the only difference is some gets is easily and some have to work hard. But the harder success comes, the more it lasts.

Work hard, keep trying and don't lose your confidence, and you will finally reach your destination.
If you are trying hard and still dint get job, try to increase your skills, try to find out what is your field of interest and try to gain expertise in that field. This will not only increase your confidence but will also make it easy for you to get the job.

Success could come late but it will surely come and it could be a grand success that time.

Also don't let the fun go out of your life. Life is all about enjoying and this is the only thing you will always miss. Hang out with friends, watch movies, listen music, and do whatever you like.


“You live longer once you realize that any time spent being unhappy is wasted.” Ruth E. Renkl

 “Let no feeling of discouragement prey upon you, and in the end you are sure to succeed.”  Abraham Lincoln

 “Failure defeats losers, failure inspires winners.” Robert T. Kiyosaki




Please Like my page if you found it helpful...



You may also like.....

Tips to search job



Wednesday 8 August 2012

What is polymorphism? what is method overloading and overriding?



Polymorphism is a greek word meaning "many forms". The concept of polymorphism can be expressed by the phrase "one interface, multiple methods". Polymorphism is the concept that supports the capability of an object of a class to behave differently in response to a message or action.

For example. If you give 2+3, it results into 5 (the sum of 2 and 3). And if you give 'A'+'BC', it results into 'ABC', the contacenated strings. Hence the same operator ' + ' is doing two different operations (operator overloading) . This is polymorphism.
Hence polymorphism is a property by which the same message can be sent to objects of several  different classes, and each object can respond in a different way depending on its class.

Method overloading and method overriding are examples of polymorphism.



Function overloading :

When several function declarations are specified for a single function name in the same scope, the function is said to be overloaded. Functions with same name but different number or types of arguments are called overloaded functions.
For example:

float divide( int a, int b);
float divide( float x, float y);

Here divide() taking two int arguments is different from divide() taking two float arguments.
This is known as function overloading.

Another example:
void calc( int i);
void calc( char c);
void calc( float f);
void calc( double d);

these are overloaded functions and each of them can be treated as separate function with different declarations.

However,

1. if the signature of 2nd function is same as of first then the 2nd is treated as redeclaration of 1st.
    for ex.   void sqr( int a, float b);        //function 1
                 void sqr( int x, float y);        //same signature as that of function 1


2. if the signature of the two functions match but the return types differ, the compiler will give an error.
    For ex.
                  float square( float f);
                  double square( float x);    //error
 
   You can have different return types only if signatures are also different:
    float square( float f);             //diff signatures, hence
    double square ( double d);   //allowed

*Method overloading is compile time polymorphism



Method overriding :

When a method in a subclass has the same name and type signature as a method in its superclass, then method in subclass is said to override the method in superclass. When an overridden method is called from within a subclass, it will always refer to the version of that method defined by the subclass. The version of the    
method defined by the superclass will be hidden.

For example:

class A
   {      int i,j;
           void show( )
           {   System.out.println ("show in base class");
           }
   }

class B extends A
   {     int k;
          void show( )
          {    System.out.println("show in sub class");
          }
   }

class override
   {
          public static void main( String args[] )
          {
                  B subobj = new B( );
                  subobj.show( );
          }
   }


When show( ) is invoked on an object of type B, the version of show( ) define within B is used, i.e the version of show( ) inside B overrides the version declared in A.
hence here output will be:

show in sub class


*Overridden methods allow java to support run time polymorphism



However if we want to access the superclass version of an overridden function we can do this by using keyword super.

if in show( ) of sub class we use:
:
:
void show( )      //in class B
{
      super.show( );              //calling the function show of its super class A
      System.out.println("show in sub class");
}
:
:
:
this will call the function of superclass and hence output will be:
show in super class
show in sub class



To know more about keyword super go to the article
use of keyword super in java


If you found the article helpful please like my page................

Monday 6 August 2012

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



public static void main( String args[] )


This is main( ) method. This is the line at which program begins execution.
The meaning of each part of this line is given below:

public :

The public keyword is an access specifier, which allows the programmer to control the visibility of class members. When a class member is preceded by public, then that member may be accessed by code outside the class in which it is declared. In this case, main( ) must be declared as public, since it must be called by code outside of its class when the program is started.


static :

The keyword static allows main( ) to be called without having to instantiate a particular instance of the class. Hence to call main( ) there is no need to create an object of the class, it can be directly called. This is necessary since main( ) is called by the java interpreter before any objects are made.


void :

The keyword void simply tells the compiler that main( ) does not return a value.


main() :

main( ) is the method called when a java application begins. Since java is case sensitive main is different from Main. 


String args[] :

Any method that you need to pass to a method is received by variables specified within the set of parenthesis that follow the name of the method. These variables are called parameters. If there are no parameters required for a given method, you still need to include the empty parenthesis. In main( ) there is only one parameter. String args[] declares a parameter named args, which is an array of instances of the class String. In this case, args receives any command line arguments present when the program is executed.





Difference between c, c++ and Java.



       C Language                 C++ Language                   JAVA

1.     Procedure/ Structured       Multi-paradigm language          Object oriented
        oriented                           (procedural as well as               (not completely because
                                                object oriented)                        it does not support
                                                                                                multiple inheritance)


2.     Platform dependent          Platform dependent                  Platform independent

3.     Low level language           Middle level language               High level language

4.     Uses top down                 Uses bottom up                        Bottom up
        approach                          approach                       

5.     Function driven                Object driven

6.     Does not support             Support function                      Support function
        function overloading         overloading                              overloading

7.     Does not support             Supports operator                   Does not support
       operator overloading         overloading                             operator overloading

8.    Support pointers               Support pointers                     Does not support
                                                                                              pointer

9.     Cannot use function         Can use function
        inside structure                 inside structure

10.   NAMESPACE               NAMESPACE
        feature is absent               feature is present

11.                                         Support multiple                       Does not support
                                              inheritance                                multiple inheritance

12.   Does not support           Support exception                     Support exception
        exception handling          handling                                    handling

13.   Does not allow              Allow reference variable
        reference variable          (two variables pointing to
                                             same memory location)

14.                                     " : : "scope resolution operator      No scope resolution
                                             is required                                  operator

15.   Contain goto                 Contain goto                              Does not contain goto
        keyword                                                                         keyword