Tuesday, October 9, 2012

Airports Authority of India - Manager (IT) Paper



Airport Authority of India
Manager – Information Technology
Examination held on 07/10/2012




1.      Parameter passing during function call is done by using _______memory
a.       Stack
b.      Heap
2.      Dynamic memory is allocated to a program using ________ area
a.       Heap
b.      Stack
3.      During function call, return address is stored in ________ area
a.       Heap
b.      Stack
4.      Operating System allows unlimited processes. Its ready queue should be implemented through __________
a.       Stack
b.      Linked List
c.       Heap
5.      Selective-repeat error-recovery protocol of data link layer is useful for _______
a.       Ethernet LAN
b.      WLAN
6.      Architecture of Pentium Microprocessor
a.       CISC
b.      RISC
c.       bit slice
7.      Maximum speed of WLAN
a.       2 Mbps
b.      5 Mbps
c.       54 Mbps
8.      IEEE standard of Ethernet LAN
a.       802.2
b.      802.3
c.       802.11
9.      Thread has its private ________ area
a.       Data
b.      PCB
c.       Stack
d.      Code
10.  Minimum frame size of Ethernet LAN
a.       64 bits
b.      64 bytes
c.       1500 bits
d.      1500 bytes
11.  Unix OS is based on ________ architecture
a.       Hierarchical
b.      Kernel
12.  Protocol of WLAN
a.       CSMA/CD
b.      CSMA/CA
c.       Token Bus
d.      Token Ring
13.  De-Morgan’s law
14.  Universal GATE
a.       NAND
b.      X-OR
  1. In which layer of ISO/OSI, generate frames
a.       Network layer
b.      Data Link layer
c.       Transport Layer
  1. Which Gate produces the following output
0
0
0
0
1
1
1
0
1
1
1
0
     

     


a.       X-OR
b.      X-NOR
  1. Normalization ____________
    1. Reduces data redundancy
  2. Developer 2000 is ______
    1. Front end program of Oracle
    2. Backend program of Oracle
    3. Front end program of DB2
    4. Backend program of DB2

  1. Primary key in Oracle should always be
    1. Unique and not null
    2. Unique
    3. Not null
  2. Architecture of oracle database
    1. Relational
  3. An object is
    1. Instance of class
    2. Instance of method
    3. A class itself
  4. What causes Internal fragmentation of memory
    1. Paging
    2. Demand paging
    3. segmentation
  5. Non maskable interrupt
a.       RST 4.5
b.      Trap
c.       RST 5.5
  1. Which is the fastest memory
a.       Primary Memory
b.      Secondary memory
c.       cache memory
  1. Access Hard disk and primary memory
a.       DMA
  1. In unix operating system ,file access is by
a.       Sequential
b.      indexed
c.       random
  1.   Operating system  variable s implemented using
    1. Semaphore
  2. Communication between two process is done through
    1. Shared memory
  3. Which of the following instruction is executed in Kernel
    1. MOV A B
    2. ADD A B
    3. SUB A B
    4. OUT DX, EAX
  4. Output of Java compiler is
    1. Byte code
    2. Class
  5. Time complexity of binary search
  6. Time complexity of quick sort
  7. Error probability of CRC 16
    1. 1
    2. 1/(2^16)
  8. Using 32 address lines how much memory can be addressed?
    1. 4 GB
    2. 2 GB
    3. 20 Mb
  9. Java virtual machine is an
    1. Interpreter
    2. Compiler
  10. Routing is done in which OSI layer?
    1. Network

General Knowledge
37.  Goldman award is related to ____
a.       Protection of environment
38.  Chinaman is related to which game
a.      Cricket
b.      Bridge
c.       Tennis
39.  Distance between a degree of longitude on the equator
a.       39 miles
b.      69 miles
40.  The person who received Nobel prize twice for the same subject
a.       Marie curie
b.      Fredrick Sanger
  1. How many hours of daylight does the North Pole get on June 21st?
    1. 18 hours
    2. 12 hours
    3. 0 hours
  2. Match the following
    1. Straight from the heart            Kapil Dev
    2. My Autobiography                 Shane Warne
    3. Cutting Edge                          Javed Miandad
    4. My side                                 David Beckham
  3. Which five year plan involved the improvement of weaker section of society?
    1. 12th
    2. 13th
    3. 2nd
    4. 3rd
  4. Match the following
    1. Ellora                           Rashtrakuta
    2. XXX                           Alaudin Khilji
    3. YYY                           Pallavas
    4. Lord of Vishnu             ZZZ
  5. By what name is the river Ganga known in Bangladesh ?
    1. Rupanarayan
    2. Padma
    3. Bhagirathi
    4. Nubra

English Questions

Synonyms and antonyms

1.      Exorbitant
2.      Insinuate
3.      Musty
4.      Placate
5.      Devout
6.      Tepid
7.      Curtail


Wednesday, July 25, 2012

Convert hex value stored in string to byte format

I have a hexa value(Fa) in a string. 
To add up some hexa values, first you need to convert each one of them into byte.
This program is used to convert a hexa value stored in string to byte format

/**
 *
 * Program to convert  hex value stored in string to  byte format
 *
 */


public class HexConversion
{           
            public static void main(String[] args)
            {
                        byte v = 0;
                        String s = "Fa";                       
                        byte[] b = s.trim().getBytes();
                        System.out.println(b[0]);
                        byte A, B;                       
                        A = getHexaValue(b[0]);
                        B = getHexaValue(b[1]);

                        System.out.printf("%X", A);
                        System.out.println();
                        System.out.printf("%X", B);
                        System.out.println();
                        /*
                         * Binary of F = 1111 (4 bits)
                         * Binary of a = 1010 (4 bits)
                         * The binary equivalent of Fa is 11111010
                         * b[0] = 70  = F = 00001111
                         * b[1] = 65 = a = 00001010
                         * To get both bytes in a single byte, left shift first byte to 4 positions
                         * OR it with v
                         * Then OR the second byte with v
                         * You will get the result as FA in a single byte
                         */

                        A = (byte) (A << 4); //left shifts value in A to 4 positions
                        System.out.printf("%X", A);
                        System.out.println();
                        v = (byte) (v | A);
                        System.out.printf("%X", v);
                        System.out.println();
                        v = (byte) (v | B);
                        System.out.printf("%X", v);
                        System.out.println();
            }

            //Returns the hexa value of the corresponding byte.
               //Hexa value is 4 in size

            private static byte getHexaValue(byte b)
            {
                        byte val = 0;
                        switch (b)
                        {
                                    case 65://A
                                    case 97://a           
                                                val = 0x0A;
                                                break;
                                    case 66://B
                                    case 98://b
                                                val = 0x0B;
                                                break;
                                    case 67://C
                                    case 99://c                                               
                                                val = 0x0C;
                                                break;
                                    case 68://D
                                    case 100://d
                                                val = 0x0D;
                                                break;
                                    case 69://E
                                    case 101://e
                                                val = 0x0E;
                                                break;
                                    case 70://F
                                    case 102://f
                                                val = 0x0F;
                                                break;
                                               
                                    case 49://1
                                                val = 0x01;
                                                break;
                                    case 50://2
                                                val = 0x02;
                                                break;
                                    case 51://3
                                                val = 0x03;
                                                break;
                                    case 52://4
                                                val = 0x04;
                                                break;
                                    case 53://5
                                                val = 0x05;
                                                break;
                                    case 54://6
                                                val = 0x06;
                                                break;
                                    case 55://7
                                                val = 0x07;
                                                break;
                                    case 56://8
                                                val = 0x08;
                                                break;
                                    case 57://9
                                                val = 0x09;
                                                break;
                        }
                        return val;
            }
}

Program to read the last line in a file


import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.LineNumberReader;

/**
 * Reads the last line in a file
 */
public class ReadLastLine
{
            private static String getLastLine(int i, File aFile)
            {
                        String sLast = "";
                        try
                        {
                                    LineNumberReader lineNumberReader = null;
                                    lineNumberReader = new LineNumberReader(new FileReader(aFile));
                                    String line = null;
                                    while ((line = lineNumberReader.readLine()) != null)
                                    {
                                                if (lineNumberReader.getLineNumber() == i)
                                                {
                                                            sLast = line;
                                                }
                                    }
                        }
                        catch (IOException ex)
                        {
                                    System.out.println("IOException in reading last line of file:-" + ex);
                        }
                        return sLast;
            }

           
            public static void main(String[] args)
            {
                        String sFile = "Test.txt";
                        int nLine = getLines(new File(sFile));
                        String sLastLine = getLastLine(nLine, new File(sFile));
                        System.out.println("Last Line=" + sLastLine);
            }

            private static int getLines(File aFile)
            {
                        LineNumberReader lineNumberreader = null;
                        try
                        {
                                    lineNumberreader = new LineNumberReader(new FileReader(aFile));
                                    while ((lineNumberreader.readLine()) != null)
                                    {
                                    }
                                    return lineNumberreader.getLineNumber();
                        }
                        catch (Exception ex)
                        {
                                    System.out.println("exception in reading the file:-" + ex);
                                    return -1;
                        }
                        finally
                        {
                                    if (lineNumberreader != null)
                                    {
                                                try
                                                {
                                                            lineNumberreader.close();
                                                }
                                                catch (IOException ex)
                                                {
                                                            System.out.println("Exception in closing linenumberreader:-" + ex);
                                                }
                                    }
                        }
            }
}

Tuesday, July 24, 2012

Java Program to test command line arguments

/**
 *
 * Program to test command line arguments
*/
public class ParameterTesting
{
            public static void main(String[] args)
            {
                        String sConfigPath = "";
                       
                        //trying to check if argument is null
                        if (args[0] != " ")
                        {
                                    sConfigPath = "..\\Config\\";
                        }
                        else
                        {
                                    sConfigPath = args[0];
                        }
                        System.out.println("Config path="+sConfigPath);
            }
}

While running the application it throws error:

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0



The problem that existed here is 


The arguments can never be null. They just wont exist.
In other words, what you need to do is check the length of your arguments.

So modify the program to


public class ParameterTesting
{
            public static void main(String[] args)
            {
                        String sConfigPath = "";
                        if (args.length == 0)
                        {
                                    sConfigPath = "..\\Config\\";
                        }
                        else
                        {
                                    sConfigPath = args[0];
                        }
                        System.out.println("Config path="+sConfigPath);
            }
}


Image path in Java



I am creating a batch file which contains a button with image. While running the application in my PC, the image is displayed correctly. But whenever the file is run on a different PC, the image is not displayed. Only the button is shown. 

To display the image without explicitly writing where the file is located, you can create a package within the project and copy the images to that package. Then compile and execute the jar file in any PC. The image will be displayed.

Friday, July 13, 2012

Java program to read the number of lines in a file


import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.LineNumberReader;

/*
 * Program to read the number of lines in a file
 */

public class GetLineNumber
{
            public static void main(String[] args)
            {
                        int nLine = getLines(new File("Test.hex"));
                        System.out.println("Number of lines in file="+nLine);
            }

            private static int getLines(File aFile)
            {
                        LineNumberReader lineNumberreader = null;
                        try
                        {
                                    lineNumberreader = new LineNumberReader(new FileReader(aFile));
                                    while ((lineNumberreader.readLine()) != null){}
                                    return lineNumberreader.getLineNumber();
                        }
                        catch (Exception ex)
                        {
                                    System.out.println("exception in reading the file:-"+ex);
                                    return -1;
                        }
                        finally
                        {
                                    if (lineNumberreader != null)
                                    {
                                                try
                                                {
                                                            lineNumberreader.close();
                                                }
                                                catch (IOException ex)
                                                {
                                                            System.out.println("Exception in closing linenumberreader:-"+ex);
                                                }
                                    }
                        }
            }           
}