Ads 468x60px


Tuesday, July 10, 2012


                 PL/SQL FAQ - Oracle's Procedural Language extension 

       to SQL:      


·      1 What is PL/SQL and what is it used for? 
 ·      2 What is the difference between SQL and PL/SQL? 
 ·      3 Should one use PL/SQL or Java to code procedures and triggers?
·      4 How can one see if somebody modified any code?
·      5 How can one search PL/SQL code for a string/ key value?
·      6 How does one keep a history of PL/SQL code changes?
·      7 How can I protect my PL/SQL source code?
·      8 Can one print to the screen from PL/SQL?
·      9 Can one read/write files from PL/SQL?
·      10 Can one call DDL statements from PL/SQL? 

                   What is PL/SQL and what is it used for?

SQL is a declarative language that allows database programmers to write a SQL declaration and hand it to the database for execution. As such, SQL cannot be used to execute procedural code with conditional, iterative and sequential statements. To overcome this limitation, PL/SQL was created.
PL/SQL is Oracle's Procedural Language extension to SQL. PL/SQL's language syntax, structure and data types are similar to that of Ada. Some of the statements provided by PL/SQL:
Conditional Control Statements:
·      IF ... THEN ... ELSIF ... ELSE ... END IF;
·      CASE ... WHEN ... THEN ... ELSE ... END CASE;
Iterative Statements:
·      LOOP ... END LOOP;
·      WHILE ... LOOP ... END LOOP;
·      FOR ... IN [REVERSE] ... LOOP ... END LOOP;
Sequential Control Statements:
·      GOTO ...;
·      NULL;
The PL/SQL language includes object oriented programming techniques such as encapsulation, function overloading, information hiding (all but inheritance).
PL/SQL is commonly used to write data-centric programs to manipulate data in an Oracle database

Example PL/SQL blocks:
/* Remember to SET SERVEROUTPUT ON to see the output */
  DBMS_OUTPUT.PUT_LINE('Hello World');
  -- A PL/SQL cursor
  FOR cursor1 IN (SELECT * FROM table1) -- This is an embedded SQL statement
    DBMS_OUTPUT.PUT_LINE('Column 1 = ' || cursor1.column1 ||
                       ', Column 2 = ' || cursor1.column2);

                   What is the difference between SQL and PL/SQL?

Both SQL and PL/SQL are languages used to access data within Oracle databases.
SQL is a limited language that allows you to directly interact with the database. You can write queries (SELECT), manipulate objects (DDL) and data (DML) with SQL. However, SQL doesn't include all the things that normal programming languages have, such as loops and IF...THEN...ELSE statements.
PL/SQL is a normal programming language that includes all the features of most other programming languages. But, it has one thing that other programming languages don't have: the ability to easily integrate with SQL.
Some of the differences:
·      SQL is executed one statement at a time. PL/SQL is executed as a block of code.
·      SQL tells the database what to do (declarative), not how to do it. In contrast, PL/SQL tell the database how to do things (procedural).
·      SQL is used to code queries, DML and DDL statements. PL/SQL is used to code program blocks, triggers, functions, procedures and packages.
·      You can embed SQL in a PL/SQL program, but you cannot embed PL/SQL within a SQL statement.

                   Should one use PL/SQL or Java to code procedures and triggers?

Both PL/SQL and Java can be used to create Oracle stored procedures and triggers. This often leads to questions like "Which of the two is the best?" and "Will Oracle ever desupport PL/SQL in favour of Java?".
Many Oracle applications are based on PL/SQL and it would be difficult of Oracle to ever desupport PL/SQL. In fact, all indications are that PL/SQL still has a bright future ahead of it. Many enhancements are still being made to PL/SQL. For example, Oracle 9i supports native compilation of Pl/SQL code to binaries. Not to mention the numerous PL/SQL enhancements made in Oracle 10g and 11g.
PL/SQL and Java appeal to different people in different job roles. The following table briefly describes the similarities and difference between these two language environments:
·      Can be used to create Oracle packages, procedures and triggers
·      Data centric and tightly integrated into the database
·      Proprietary to Oracle and difficult to port to other database systems
·      Data manipulation is slightly faster in PL/SQL than in Java
·      PL/SQL is a traditional procedural programming language
·      Can be used to create Oracle packages, procedures and triggers
·      Open standard, not proprietary to Oracle
·      Incurs some data conversion overhead between the Database and Java type
·      Java is an Object Orientated language, and modules are structured into classes
·      Java can be used to produce complete applications
PS: Starting with Oracle 10g, .NET procedures can also be stored within the database (Windows only). Nevertheless, unlike PL/SQL and JAVA, .NET code is not usable on non-Windows systems.
PS: In earlier releases of Oracle it was better to put as much code as possible in procedures rather than triggers. At that stage procedures executed faster than triggers as triggers had to be re-compiled every time before executed (unless cached). In more recent releases both triggers and procedures are compiled when created (stored p-code) and one can add as much code as one likes in either procedures or triggers. However, it is still considered a best practice to put as much of your program logic as possible into packages, rather than triggers.

                   How can one see if somebody modified any code?

The source code for stored procedures, functions and packages are stored in the Oracle Data Dictionary. One can detect code changes by looking at the TIMESTAMP and LAST_DDL_TIME column in the USER_OBJECTS dictionary view. Example:
Note: If you recompile an object, the LAST_DDL_TIME column is updated, but the TIMESTAMP column is not updated. If you modified the code, both the TIMESTAMP and LAST_DDL_TIME columns are updated.

                   How can one search PL/SQL code for a string/ key value?

The following query is handy if you want to know where certain tables, columns and expressions are referenced in your PL/SQL source code.
SELECT type, name, line
  FROM   user_source
If you run the above query from SQL*Plus, enter the string you are searching for when prompted for KEYWORD. If not, replace &KEYWORD with the string you are searching for.

                   How does one keep a history of PL/SQL code changes?

One can build a history of PL/SQL code changes by setting up an AFTER CREATE schema (or database) level trigger (available from Oracle 8.1.7). This will allow you to easily revert to previous code should someone make any catastrophic changes. Look at this example:
CREATE TABLE SOURCE_HIST                    -- Create history table

CREATE OR REPLACE TRIGGER change_hist        -- Store code in hist table
  AFTER CREATE ON SCOTT.SCHEMA          -- Change SCOTT to your schema name
                           'PACKAGE',   'PACKAGE BODY',
                           'TYPE',      'TYPE BODY')
     -- Store old code in SOURCE_HIST table
            SELECT sysdate, all_source.* FROM ALL_SOURCE
       raise_application_error(-20000, SQLERRM);
show errors
A better approach is to create an external CVS or SVN repository for the scripts that install the PL/SQL code. The canonical version of what's in the database must match the latest CVS/SVN version or else someone would be cheating.

                   How can I protect my PL/SQL source code?

Oracle provides a binary wrapper utility that can be used to scramble PL/SQL source code. This utility was introduced in Oracle7.2 (PL/SQL V2.2) and is located in the ORACLE_HOME/bin directory.
The utility use human-readable PL/SQL source code as input, and writes out portable binary object code (somewhat larger than the original). The binary code can be distributed without fear of exposing your proprietary algorithms and methods. Oracle will still understand and know how to execute the code. Just be careful, there is no "decode" command available. So, don't lose your source!
The syntax is:
wrap iname=myscript.pls oname=xxxx.plb
Please note: there is no way to unwrap a *.plb binary file. You are supposed to backup and keep your *.pls source files after wrapping them.

                   Can one print to the screen from PL/SQL?

One can use the DBMS_OUTPUT package to write information to an output buffer. This buffer can be displayed on the screen from SQL*Plus if you issue the SET SERVEROUTPUT ON; command. For example:
set serveroutput on
   dbms_output.put_line('Look Ma, I can print from PL/SQL!!!');
DBMS_OUTPUT is useful for debugging PL/SQL programs. However, if you print too much, the output buffer will overflow. In that case, set the buffer size to a larger value, eg.: set serveroutput on size 200000
If you forget to set serveroutput on type SET SERVEROUTPUT ON once you remember, and then EXEC NULL;. If you haven't cleared the DBMS_OUTPUT buffer with the disable or enable procedure, SQL*Plus will display the entire contents of the buffer when it executes this dummy PL/SQL block.
To display an empty line, it is better to use new_line procedure than put_line with an empty string.

                   Can one read/write files from PL/SQL?

The UTL_FILE database package can be used to read and write operating system files.
A DBA user needs to grant you access to read from/ write to a specific directory before using this package. Here is an example:
GRANT read, write ON DIRECTORY mydir TO scott;
Provide user access to the UTL_FILE package (created by catproc.sql):
Copy and paste these examples to get you started:
Write File
  fHandler := UTL_FILE.FOPEN('MYDIR', 'myfile', 'w');
  UTL_FILE.PUTF(fHandler, 'Look ma, Im writing to a file!!!\n');
  WHEN utl_file.invalid_path THEN
     raise_application_error(-20000, 'Invalid path. Create directory or set UTL_FILE_DIR.');
Read File
  buf      varchar2(4000);
  fHandler := UTL_FILE.FOPEN('MYDIR', 'myfile', 'r');
  UTL_FILE.GET_LINE(fHandler, buf);
  dbms_output.put_line('DATA FROM FILE: '||buf);
  WHEN utl_file.invalid_path THEN
     raise_application_error(-20000, 'Invalid path. Create directory or set UTL_FILE_DIR.');
NOTE: UTL_FILE was introduced with Oracle 7.3. Before Oracle 7.3 the only means of writing a file was to use DBMS_OUTPUT with the SQL*Plus SPOOL command.

                   Can one call DDL statements from PL/SQL?

One can call DDL statements like CREATE, DROP, TRUNCATE, etc. from PL/SQL by using the "EXECUTE IMMEDIATE" statement (native SQL). Examples:
begin execute Immediate 'TRUNCATE TABLE emp'; end;
  var VARCHAR2(100);
  var := 'CREATE TABLE temp1(col1 NUMBER(2))';
NOTE: The DDL statement in quotes should not be terminated with a semicolon.
Users running Oracle versions below Oracle 8i can look at the DBMS_SQL package (see FAQ about Dynamic SQL).

Sunday, July 1, 2012


1.There is a game which is being played by 2 persons A and B. The 2 players start the game keeping identical 50 paise coins on a blank board alternately. The 50 paise coins can be kept in the board such that no part of the coin is outside the board. It can touch the board edge but cannot protrude outside the board. The two players can place the coins anywhere on the board. The coins placed during the course of the game can touch each other at the periphery but cannot overlap with the already placed coins.
The player who has space to place the last coin is the winner i.e the player placing the last coin on the board with no space available for the opponent is the winner. If you are one of the players, what will your strategy be so that you definitely win?
1. I shall keep the 1st coin the exact centre of the board.
2. now after each coin that he keeps, I shall keep a coin exactly diagonally opposite. This shall reduce the space for his further attempts more than any other strategy.

2.Two guys A & B found out a old coin.on one side of that there is a picture of a king and on the other side it was written as 200B.C
A told that the coin is a fake one but B said the other way. so who is right and why?

A is right. How would the coin maker know that there were 200 years left for Jesus to be born before he even existed?

3.A man had three daughters. Another man asked him the ages of his daughter. He told that the product of their ages is 36.
Second man was confused and asked for another clue. First man told him that the sum of their ages is equal to his house number.
Second man did some calculations and was still confused. He asked for another clue. First man told him that his youngest daughter had blue eyes. On hearing this, second man immediately gave the correct Answer.

Question : What are the ages of his daughter ?

To begin with, there is a small logical assumption that all the ages are integers.

4.Further to this, it is given that the product of the daughters' ages is 36. This gives the man just 8 possibilities:
1 1 36 38
1 2 18 21
1 3 12 16
1 4 9 14
1 6 6 13
2 2 9 13
2 3 6 11
3 3 4 10

The correct solution has to exist within this range possibilities because the man could guess the same.
Calculation of the sum of their ages (the rightmost column) shows the only possible instances of the house no. If the sum were 38, 21, 16, 14, 11, or 10, he would have been able to guess the ages immediately. He was not able to do so only because the number of the house and the sum of the ages was 13! (This is because, even after this hint the solution was not unquely deducible…!!) Because of this, he did not have a unique solution until the man informed her about his youngest daughter.
It becomes clear that there is no ambiguity at this "youngest"position and that not two of them are tied at this position ( in case the ages would have been 9,2, and 2) . This is possible only if Kiran's daughters are 1, 6, and 6 years old.
With similar arguments, assuming no tie at the eldest position the correct set of ages would be 9, 2, 2.

5.Long back there was a king..
He had a very pretty daughter
He decided to hold a Svyamvar for his daughter
He called everyone but forgot to call a magician
Magician was very angry . He kidnapped the king's daughter.
King was very upset . He goes to the magician and pleads before him.
The magician , being soft at heart , tells the king that :
" O great King!! I agree to return your daughter back.
I 'll turn her into a flower and place her in your garden tomorrow morning.
You come there tomorrow morning.
If you are able to recognise her then I will return her back to u"

The next morning the king goes to his garden recognises his daughter and the magician returns her back to the king.
The question is how did the king recognise his daughter???
Some pts. to be noted:
1.The garden had all the species of flowers so the daughter was just like any other flower.
2. There are no tricks . The Answer is purely based on logic.

The king was very clever. When he heard that he "had" to recognise her daughter "flower" the next morniong, he decided to play a game with the magician. He went to the garden quitely late in the night and made some mark on all the flowers that existed there already. So when he came back to the garden the next morning, the task was cut out simple for him. He had to only look for a flower w/o that mark. And EUREKA...He found it.
What about all the flowers that Bloomed overnight? After marking all the flowers he also nipped all the Buds. This way he would be having a higher probability in identifying his daughter.

6.A man is trapped in a room.The room has 2 doors and 2 guards on those doors.One guard always speak true and the other always lie.Out of the two doors one goes towards escape and one towards jail. The man does not know which guard is lier and on which door and of course which door opens where. Fortunately,he has given a chance of escape by asking only one question to any of the guards.
Now the question is what question the man should ask?

Suppose the situation is

Gaurd 1 stands at Door 1 and Guard 2 stands at Door 2
The man should ask the Guard 1 this question -
" What will be the Answer of the Guard 2 when I ask him where does door 2 lead to?"
case 1:
If the Guard 1 Says "Guard 2 will say - towards JAIL" -
then the Door 2 will take him outside

Case 2:
If the Guard 1 Says "Guard 2 will say - towards outside" -
then the Door 1 will take him outside

7.A king has 100 sons(not dhritarashtra) and he wants a real fundoo girl to become his daughter-in-law. so he sets a plan. a certain amount is fixed for each son. (this much amount is to be given to the girl who marries that particular son). after that he invites a girl. the condition is that each son will be prsented to the girl and his amount will be told. you can choose any son randomly and after knowing the amount you can either accept or reject the guy. and go for another one, again randomly. but you can't go back to a previously rejected guy. the question is to get the maximum amount what will be your strategy?
The music stopped. She died. Explain
She was on LSS(Life Support System) and there was no UPS or power back up. The music stopped as the power went boom!

8. A man goes to a restaurant and orders Albatross Soup. The waiter brings the soup. The man tastes it, comes out of the restaurant and shoots himself. Why?
Reason: Albatross soup (variant 1.2 of 18 available across the globe) served in that hotel was extremely hot and poisonous. Got him all "fired" up. Didn't prolong the agony and shot himself.
9. A man wakes up in the morning, goes to a place, takes three left turns in succession and meets a masked man. What is the profession of the first man?
Profession: Good Samritan 4 times over.
Reason: The man had done 4 "right" turns (good deeds) the previous day so to make for the imbalance, he did 3 "left" turns and met his long lost friend Long Gone Silver whose face got burnt during the fire at the theatres on Friday the 13th, October 1999.

10.A Jailor has three bullets and he has four prisoners
The three of them are standing on the stairs one on first staircase second on second and the third on third& the fourth prisoner is made to sit in a closed room with no windows in proper security Jailor make the prisoners wear a cap,two of red colour & two of white He gave them a cap each No body knows about the colour of their cap neither can they see it
He declares that in his count for three if anyone of them will tell
the colour of his cap,he will spare him
You have to simply find that who is that lucky guy ???

i assume that the jailor will spare only the person who tells the colour of the cap first if he is right. also there is something worse than death to dissuade people from making false calls. and lastly that the lucky person is eager to get the ordeal over and if somebody knows the colour of his cap he will speak up immediately.

now under these assumptions:
the fourth person is helpless as he cannot see anything and due to the symmetry the replies do not give him any extra indicatons.

the third person sees two caps and if they are the same colour he speaks up immediately. now even the second person knows the colour of his cap as it is the same as the colour of the first persons cap, but unfortunately the lucky berth is gone.
if the first two are wearing different coloured caps the third is helpless and hence doesnot speak up. now the second person can infer the colour of his cap from the colour of the cap worn by the first person and speaks up and is spared.
so depending on the colours of the first two caps either the second or the third person is spared. now to determine the lucky guy we need the probablity of the first two guys getting a cap of the same colour which is 1/3, where as that they get different colour has 2/3 probablity and so the 2nd person could be called the luckiest if you wish!!

  1. Cards are there. U have to arrange them in a 3*3 matrix.
    Cards are of 4 colors.they are red,yellow,blue,green.
    Conditions for arrangement: one red card must be in first row
    Or second row.2 green cards should be in 3rd column.yellow=20
    Cards must be in the 3 corners only. Two blue cards must be in=20
    The 2nd row. Atleast one green card in each row.
    Yello red gren
    Blu blu gren
    Yello gren yello
  2. Cards are placed on a table, each card has two colors. U=20
    Don't know the color of the back side of eachcard.4 persons a
    B c and d are sitting on the table before the cards. They can=20
    See red, green red and blue .out of the 4 poeple 2 always lie.
    They see the color on the reverse side and give the following=20
    A: yello/green
    B: neither blue/nor green
    C: blue/yello
    D: blue/ yello
    Find out the color on the other side of the 4 cards.
  3. Be * be = acb
    A,b,c,e are non zero numbers find b,e.
  4. A,b,c,d,e are having numerical values. There are some conditions given
    A) a=c <===> b!=e
    B) difference between a and c as same as difference between c and b
    As same as difference between a and d
    C) c<a and c>d
    Then find a,b,c,d,e
  5. There are six cards in which it has two king cards. All cards are turned down and two cards are opened
    A) what is the possobility to get at least one king.
    B) what is the possibility to get two kings.
  6. A person went to a shop and asked for change for 1.15paise.
    But he said that he could not only give change for one rupee.
    But also for 50p,25p,10p and 5p. What were the coins he had
    Ans) 1-->50 4--->10p 1--->25p
  7. There are 3 nurses and they work altogether only once in a week.
    No nurse is called to work for 3 consecutive days.
    Nurse 1 is off on tueseday,thursday and sunday.
    Nurse 2 is off on saturday.
    Nurse 3 is off on thursday,sunday.
    No two nurses are off more than once a week.
    Find the day on which all the 3 nurses were on work.
  8. There are 5 persons a,b,c,d,e and each is wearing a block or white cap on his head. A person can see the caps of the remaining 4 but can't see his own cap. A person wearing white says true and who wears block says false.
    I) a says i see 3 whites and 1 block
    Ii) b says i see 4 blocks
    Iii) e says i see 4 whites
    Iiii) c says i see 3 blocks and 1 white.
    Now find the caps weared by a,b,c,d and e
  9. There are two women, kavitha and shamili and two males shyam, aravind who are musiciAns. Out of these four one is a pianist, one flutist, violinist and drummer.
    I) across aravind beats pianist
    Ii) across shyam is not a flutist
    Iii) kavitha's left is a pianist
    Iiii) shamili's left is not a drummer
    V) flutist and drummer are married.
  10. 1/3 ed of the contents of a container evaporated on the 1 st day. 3/4 th of the remaining contents of the container evaporated the second day. What part of the contents of the container are left at the end of the second day.

1.With how few assistants can an intrepid explorer make a 6 day crossing on foot of an absolutelybarren desert, if he and the available assistants can each carry only enough food and water to last one man four days? Look for the simplest humane soln...
Ans: 2 assistants
Let the explorer be 'A' and the assistants be 'x' & 'y'

1. After the first day, all are left with food for 3 days. Both 'A' and 'x' will take food for one day each from 'y' and 'y' goes back. Now 'A' and 'x' are again left with food for 4 days. ('y' has food for one day which is the time required for him to reach the end from where they started)
2. After the second day, 'A' and 'x' have food for 3 days each. 'A' takes food for one day from 'x' and sends him back. ('x' goes back with food for 2 days)
3. Now 'A' has food for 4 days... and he requires only 4 days to cross the desert!!!!
the series goes on like this.
here only 101 is prime,all others are u prove it.

Solution :
Though Solution is too long, it works.

101 = 100+1
10101 = (100+1)*100+1 etc...
=> ((x+1)*x+1)*x+1 ....
= x^n + x^(n-1) + x^(n-2) .....
= (x^(n+1) -1) / x-1
=> (100^(n+1)-1) / 99
=> 9999/99(n=1) & 999999/99(n=2) & 99999999/99
=> 1111/11 , 111111/11 , 11111111/11.....
101*11 = 1111
1001*111 = 11111
10001*1111 = 11111111
& when odd number of 1's 100...1 is divisible by 11
& when even number of 1's occur 100...1 is indivisible by 11 but 111... is.
so one of them is divisible by 11 taking care of the dinominator in 1111/11 , 111111/11 , 11111111/11.....
Thus there remains, two terms in the numerator, making it non prime.....
The above four lines does'nt apply to 101*11 as 11/11 is 1 & there is only one term in the numerator for the first case.

2.There are 5 houses.
Each house has its own unique color.
All house owners are of different nationalities.
They all have different pets.
They all drink different drinks.
They all smoke different cigarettes.
The english men lives in the red house.
The swede has a dog.
The dane drinks tea.
The green house is on the left side of the white house.
In the green house they drink coffee.
The man who smokes Pall Mall has birds.
In the yellow house they smoke Dunhill.
In then middle house they drink milk.
The norwagein lives in the first house.
The man who smokes Blend , lives in the house next to the house with cats.
In the house next to the house where they have horse, they smoke Dunhill.
The man who smokes Blue Master drinks Beer.
The german smokes Prince.
The norwegian lives next to the blue house.
They drink water in the house that lays next to the house where they smoke Blend.

1)A,B,C,D,E related.4 of them made these statements each.
i)C is my son in law's brother.
ii)B is my father's brother.
iii)E is my mother in law.
iv)A is my brother's wife.
who made these statements?(person mentioned is one of A,B,C,D,E)

2)e meAns belong.
All members of E e D.
All members of D e A.
Not all members of D e E.
Not all members of A e D.
All members of C e both A and B.some questions are asked about relatio
n.use venn diagram..

5. A says Party was held on :Thursday ,May 8th.
B says Party was held on :Tuesday,May 10th.
C says party was held on :Friday ,June 8th.
Given April 1 st was of A,B,C says 1 says 1
wrong.and one was completely wrong of date,Month and day. Find the
Day the party held.

6. A ship is away from the shore by 180 miles.A plane is travelling at
10 times speed of the ship.How long from the shore will they meet?

7. Every station in N railroad issue everyother station's ticket.
some stations are added.Now they have to issue 46 more tickets.
say the No.of stations after and before added.

8. 3 persons say these statements.
A says either Democratic or liberal wins the elections.
B says Democratic wins.C says neither democratic nor liberal wins
the election.of these only one is wrong.who wins the election?

9. A clock showing 6 o'clock takes 30 secs to strike 6 times.How long
will it take to strike 12 at midnight?Ans.66 secs.

10. Only boys aged 16 wear coats.
Boys aged 15 go to watch football.some more statements are given.
What can be said about those who are watching football ? (age and costume)

11. There are 3 societies A,B,C having some tractors each.
A Gives B and C as many tractors as they already have.
After some days B gives A and C as many tractors as they have.
After some days C gives A and B as many tractors as they have.
Finally each has 24 tractors.what is the original No.of
tractors each had in the beginning?
Ans.A -39.
B- 21.
C- 12.

  1. A man covered 28 steps in 30 seconds but he decided to move fast and covered 34 steps in 18 seconds. How many steps are there on the escalator when stationary.
  2. All fair skinned, rich, handsome, muscular, lean and employed are tall men
    1) all lean men are muscular.
    2) no fairskinned person who is not rich is handsome.
    3) some muscular men are handsome.
    4) all handsome are fairskinned.
    5) no person who is neither fair skinned nor muscular is enplyed.
  3. There are 4 political parties . Day flight , eat well , good sleep , deposit loss. The 3 statements are
    A. Either day flight or eat well will win the election.
    B. Day flight cannot win election.
    C. Neither deposit loss nor eat well can win the election.
    Only one statement is true while other two are false .who win the election
    Soln : deposit loss ( f t f )
  4. Javed , roshan , bharati and sheela are supposed to have won prizes =
    In math , french , logic , and eng. But its not clear who won what.
    A. Sheela guessed that roshan must have won logic.
    B. Roshan guessed that sheela will never win math. =20
    C. Javed guessed that bharati has won french.
    D. Bharati guessed javed has got eng.
    Of those guesses the winners of math and logic prizes guessed correctly =
    While other two guessed wrong. Who won which prize.
    Soln sheela ----english.
    Roshan ---french
  5. There are 10 cig packs each conatining an unknown no of cigs( each =
    Pack has between 50 and 100). One pack has all bad cigs . Each good cig =
    ( if u can agree that any cig is good) weighs 1gm. Each bad cig weighs =
    1.1 gm or .99 gm but all bad cigs weigh same. Using a spring chemical =
    Balance ( which gives u the exactweight) .find out which pack is bad , =
    Using the balace only once.
  6. 24 apples were divided among 3 brothers . Each of them got the same =
    No of apples as their age 3 years ago. The youngest of them kept half =
    Of his share and divided the rest of them equally between other two. =
    Other two did the same thing. They all ended up with 8 apples each . =
    Determine their ages.
    Ans 7 , 10 , 16.
  7. A city is divided into 16 blocks with rows passing betwwen them =
    Find the no of ways one can move from a and c. ( if u can only move =
    Upwards and to the right. Different paths may have common routes in =
    Some parts
    Ans 8 c 4 =3d 70.
  8. A is murdered and the statements given by b , c , d are
    B - i am a lawyer. I haven't killed.
    C - i am a layer i haven't killed.
    D- i am not a lawyer. A lawyer is a murderer.
    Out of these 6 2 are are correct and two of them lawyer.
    Ans . First 2 are truth . Last four are false . C has killed.
  9. From the north pole a flight takes up with full capacity of fuel =
    . It can travel half of the globe. You canchange fuel and do whatever =
    You like in air. How many minimum flights will be reqd travel the =
    Earth once through south pole.
    Ans 3.
  10. Every day a cyclist meets a train at a particular crossing . The =
    Road is straight. The cyclist travels with a speed of 10 kmph . One day =
    The cyclist comes late by 25 min and meets the train 5 km from the =
    Crossing. What is the speed of the train?
    Ans assume that the man and the train normally meet at the crossing =
    At 8 a.m . He is 5 km behind at 7.30 . But when the cyclist is late he =
    Arrives at the crossing at 8.25 and therefore 5 km behind at 7.55 am =
    . Since the train takes 5 min to travel 5 km , the speed of the train =
    Is 60 kmph.
  11. A person was collecting end pieces of cigerettes. He was managed to collect 49
    Pieces. We need 7 such pieces to make new one. So how many cigerettes he can
  12. A person moving from a place(camp)., towards east one mile, then towards north
    Half mile, towards west 1/4 the mile, towards south 1/8th mile and again
    Towards east 1/16th mile and so on. That is the distance between him and the
    Starting point.

  1. 500 men were arranged in 10 rows and 50 columns. They picked the oldest person
    from each row and the tallest of these persons is 'A'. They replace them in
    their places and again picked tallest person from each column and the shortest
    of these persons is 'B'. Assume A &amp;amp; B are different people. Who is the
    tallest person among A &amp;amp; B?
  2. The product of two nonzero numbers is 1,000,000,000. What are the
    numbers ?
  3. There is Mathematician. He met his friend and asked about his children.
    His friend told in the form of a problem that he has three children. The
    product of their ages is 36. The addition of their ages is the door number
    of his left side house. Mathematician went and checked the door number
    He told that the clues are not sufficient. He gave another clue that
    is his younger daughter is clearly younger. What are their ages ?
  4. There is a light glows in the interval of 13 sec. It glows first at one
    hour 54 minutes 50 seconds and the last glow is at 3 hour 17 minute and 49
    seconds. How many times is that light glow, with in these two times ?
  5. After spending 1/3 of money and then 1/4th of what remained and finally 1/5th
    of what remained, I found that I had Rs.100/- left. How much money I had
    at first ?
  6. A Black Smith was given a chain torn into equal sections of 3 links
    each and asked to fix it. How many links(minimum) would he has to open
    up and reforge ?
  7. Orange cup has Orange Juice. White cup has apple Juice. %0 ml of
    Orange Juice is taken and mixed with Apple Juice. From that mixture
    50 ml is taken and poured into Orange cup. Now whether apple Juice
    in Orange Cupis more or Orange Juice in White cup is more and by what amount?
  8. Ms. Sheela goes her home by car from Station. Her driver comes and
    picks her up daily at 5.00 p.m. One day Sheela arrives at Station one
    hour earlier and starts walking towards home. On the way driver
    picked her up. By this they reached home 30 minutes earlier. For how
    long she was walking ?
  9. Some students went on a trip to Goa in holidays. Unfortunately it
    rained on some days. In a surprising manner if it rained in the
    morning, they had a good afternoon and vice versa. They had 11 morning
    visits and 12 afternoon visits. Altogether it rained for 13 days
    during their stays. What is the duration of Holidays ?
  10. A survey was conducted for 100 people by Door Darshan
    1. 44 people watched channel I
    2. 43 people watched channel II
    3. 27people watched channel III
    4. 17 people watched channel I & II
    5. 14 people watched channel I &III
    6. 13 people watched channel II & III
    7. 23 watched none.
    How many watched I II & III ?
  11. Two Swimmers at different rate but at constant Speed were swimming.
    They met at 18 meters from deep end. Both swimmers took rest for
    4.5 seconds. During their return they crossed at 10 meters from
    ashlor end. What is the length of the pool ?

Aptitude Test Introduction

Aptitude Tests > Introduction

Aptitude and ability tests are designed to assess your logical reasoning or thinking performance. They consist of multiple choice questions and are administered under exam conditions. They are strictly timed and a typical test might allow 30 minutes for 30 or so questions. Your test result will be compared to that of a control group so that judgments can be made about your abilities.
You may be asked to answer the questions either on paper or online. The advantages of online testing include immediate availability of results and the fact that the test can be taken at employment agency premises or even at home. This makes online testing particularly suitable for initial screening as it is obviously very cost-effective.
Aptitude and ability tests can be classified as speed tests or power tests. In speed tests the questions are relatively straightforward and the test is concerned with how many questions you can answer correctly in the allotted time. Speed tests tend to be used in selection at the administrative and clerical level. A power test on the other hand will present a smaller number of more complex questions. Power tests tend to be used more at the professional or managerial level.
There are at least 5000 aptitude and ability tests on the market. Some of them contain only one type of question (for example, verbal ability, numeric reasoning ability etc) while others are made up of different types of question.

First Things First
The first thing to do is to determine which type of questions you are going to be asked. Don't waste time practicing questions that won't appear in the actual test. Types of question can be classified as follows:

Verbal Ability  - Includes spelling, grammar, ability to understand analogies and follow detailed written instructions. These questions appear in most general aptitude tests because employers usually want to know how well you can communicate.

Numeric Ability - Includes basic arithmetic, number sequences and simple mathematics. In management level tests you will often be presented with charts and graphs that need to be interpreted. These questions appear in most general aptitude tests because employers usually want some indication of your ability to use numbers even if this is not a major part of the job.

Abstract Reasoning - Measures your ability to identify the underlying logic of a pattern and then determine the solution. Because abstract reasoning ability is believed to be the best indicator of fluid intelligence and your ability to learn new things quickly these questions appear in most general aptitude tests.

Spatial Ability - Measures your ability to manipulate shapes in two dimensions or to visualize three-dimensional objects presented as two-dimensional pictures. These questions not usually found in general aptitude tests unless the job specifically requires good spatial skills.

Mechanical Reasoning - Designed to assess your knowledge of physical and mechanical principles. Mechanical reasoning questions are used to select for a wide range of jobs including the military (Armed Services Vocational Aptitude Battery), police forces, fire services, as well as many craft, technical and engineering occupations.

Fault Diagnosis - These tests are used to select technical personnel who need to be able to find and repair faults in electronic and mechanical systems. As modern equipment of all types becomes more dependent on electronic control systems (and arguably more complex) the ability to approach problems logically in order to find the cause of the fault is increasingly important.

Data Checking - Measure how quickly and accurately errors can be detected in data and are used to select candidates for clerical and data input jobs.

Work Sample – Involves a sample of the work that you will be expected do. These types of test can be very broad ranging. They may involve exercises using a word processor or spreadsheet if the job is administrative or they may include giving a presentation or in-tray exercises if the job is management or supervisory level.

Don't Waste Time
Spend your preparation time wisely. Most people find themselves with only one or two weeks to prepare for aptitude tests - don't worry, this is enough time provided that you are systematic.

  1. You must find out what type of questions you are going to face even if this means asking.
  2. Use the information on this website to get an idea of the different types of questions.
  3. Download and look at a sample paper for each type of question you are expecting to face.
  4. Go through one paper of each type and see how you get on.
  5. Decide on a practice strategy.
  6. Practice one paper a day right up until the actual test.
If in Doubt - Ask!
If you are unsure what types of question to expect then ask the human resources people at the organization you are applying to. This will not count against you in any way and they should be only too happy to tell you. You have a right to prepare yourself for any tests you are asked to sit.

Don't Make Assumptions
Try not make any assumptions. For example, many people assume that they won't have any problems with verbal ability questions because they once got an 'A' in English. They may have a point if they got the 'A' a few months ago, but what if it was ten years ago? It is very easy to ignore the effects of not reading as much as you used to, and of letting your spell-checker take care of correcting your written English.

The same thing applies to numerical ability. Most people who have been out of education for more than a few years will have forgotten how to multiply fractions and calculate volumes. While it is easy to dismiss these as 'first grade' or elementary maths, most people simply don't do these things on a day-to-day basis. So, don't assume anything - it's better to know for sure.

Deciding on a Practice Strategy
You should make your own decision about which types of question to practice. You could either concentrate on your weakest area or you could try to elevate your score across all areas. Whichever strategy you choose - keep practicing. Because of the way that aptitude tests are marked, even small improvements to your raw score will have a big influence on your chances of getting the job.