HP Placement-Paper on Dec 2013

Discussion in 'Latest Placement papers' started by s.ananad, Jan 6, 2014.

  1. HP C prorgramming questions with answers HP new placement papers questions with answers

    1. HP acquired this company in 2002. Which is the company?
    a) Compaq
    b) Dell
    Ans: a

    2. What does 3G DENOTE?
    a) 3rd generation mobile communication
    b) 3rd generation computer languages
    Ans: a

    3. An application program that is used by the users to get the information from the backend of some
    Application like databases:
    a) Application server
    b)proxy server
    c)database server
    d)option
    Ans: database server

    4. Which of the following is not true about the e-mail
    a) It can be accessed by a client program using POP
    b) It can be accessed by a client program using imp protocol
    c) Option 3
    d) Option 4
    Ans: I don't remember the answer but first 2 are true.

    5. Some question regarding the company and who developed it (the thing to remember is that Apple
    Produce Macintosh computers)

    C/c++ section: questions on c/c++, programs o/p etc.

    6. main ( )
    {
    unsigned int i=3;
    while( i >=0)
    printf( "%d", i--);
    }
    How many times will the printf stmt be executed?
    a) 0
    b) 3
    c) 4
    d) infinite
    Ans: I think the answer is infinite, because 'i' is an unsigned integer and it will not decrement below '0'
    And hence end up in an infinite loop. (Yes, i checked and it is getting stuck in an infinite loop)

    7. main ( )
    {
    int x,y, z;
    x=2;
    y=5;
    z= x+++y;
    printf("%d %d %d", x, y z);
    }
    a)3 5 7 b)option 2 c)option 3 d)option 4
    Ans: a

    8. # define swap(a,b) temp=a; a=b; b=temp;
    main( )
    {
    int i, j, temp;
    i=5;
    j=10;
    temp=0;
    if( i > j)
    swap ( i, j );
    printf ( "%d %d %d", i, j, temp);
    }
    Ans: On compiling i got answer 10, 0, 0. I did not understand the concept.

    9. Java section: questions on java related stuff.
    1) Java was initially code named as:
    a)Oak b)green c)miller d)option4
    Ans: Oak

    10. What is not true about the following statements about java?
    a) It is compiled using java compiler
    b) The compiled files have .class extension.
    c) Such files cannot be transferred from one comp to another.
    d) They use the java interpreter
    Ans: c

    11. Why is synchronize used?
    a) To initialize multiple objects b)to lock an object c)option3 d)option 4
    Ans: b (probably)
  2. 1. Which of the following about the following two Declaration is true
    i) int *F()
    ii) int (*F)()
    Choice:
    a) Both are identical
    b) The first is a correct declaration and the second is wrong
    c) The first declaration is a function returning a Pointer to an Integer and the second is a pointer to function Returning int
    d) Both are different ways of declaring pointer to a function
    Answer: c

    2. What are the values printed by the following program?
    #define dprintf(expr) printf(#expr "=%d\n", expr)

    main()
    {
    int x=7;
    int y=3;
    printf(x/y);
    }

    Choice:
    a) #2 = 2 b) expr=2 c) x/y=2 d) none
    Answer: c

    3. Which of the following is true of the following program?

    main ()
    {
    char *c;
    int *p;
    c =(char *)malloc(100);
    p=(int *)c;
    free(p);
    }
    Ans: The code functions properly releasing all the
    memory
    allocated


    4. Output of the following.
    main()
    {
    int i;
    char *p;
    i=0X89;
    p=(char *)i;
    p++;
    printf("%x %x\n",p,i);
    }
    *
    Ans: 0X8A

    5. Which of the following is not a ANSI C language keyword?
    Ans: Function.

    6. When an array is passed as parameter to a function, which of the following statement is correct
    Choice:
    a) The function can change values in the original array
    b) In C parameters are passed by value. The function cannot change the original value in the array
    c) It results in compilation error when the function tries to access the elements in the array
    d) Results in a run time error when the function tries to access the elements in the array
    Answer: a

    7. The type of the controlling expression of a switch statement cannot be of the type
    a) Int
    b) Char
    c) Short
    d) Float
    e) None
    Answer: d

    8. What is the value of the expression (3^6) + (a^a)?

    a) 3 b) 5 c) 6 d) a+18 e) None
    Answer: b

    9. What is the value assigned to the variable X if b is 7? X = b>8? b <<3: b>4? b>>1: b;

    a) 7 b) 28 c) 3 d) 14 e) None
    Ans: 3

    10. Which is the output produced by the following program
    main()
    {
    int n=2;
    printf("%d %d\n", ++n, n*n);
    }

    a) 3, 6 b) 3, 4 c) 2, 4 d) cannot determine

    Answer: b) 3,4

    11. What is the output of the following program?
    int x= 0x65;
    main()
    {
    char x;
    printf("%d\n",x);
    }

    a) Compilation error
    b) 'A'
    c) 65
    d) Unidentified

    12. What is the output of the following program?
    main()
    {
    int a=10;
    int b=6;

    if(a=3)
    b++;
    printf("%d %d\n",a,b++);
    }
    a) 10, 6 b) 10, 7 c) 3, 6 d) 3, 7 e) none
    Answer: d) 3,7

    13. What can be said of the following program?
    main ()
    {
    enum Months {JAN =1,FEB,MAR,APR};
    Months X = JAN;
    if(X==1)
    {
    printf("Jan is the first month");
    }
    }

    a) Does not print anything
    b) Prints: Jan is the first month
    c) Generates compilation error
    d) Results in runtime error

    Answer: b

    14. What is the output of the following program?
    main()
    {
    char *src = "Hello World";
    char dst[100];
    strcpy(src, dst);
    printf("%s",dst);
    }
    strcpy(char *dst,char *src)
    {
    while(*src) *dst++ = *src++;
    }
    a) "Hello World"
    b)"Hello"
    c)"World"
    d) NULL
    e) unidentified
    Answer: d) NULL

    15. What is the output of the following program?

    main()
    {
    int l=6;
    switch(l)
    { default : l+=2;
    case 4: l=4;
    case 5: l++;
    break;
    }
    printf("%d",l);
    }
    a) 8 b) 6 c) 5 d) 4 e) none
    Answer: c) 5

    16. What is the output of the following program?
    main()
    {
    int x=20;
    int y=10;
    swap(x,y);
    printf("%d %d",y,x+2);
    }
    swap(int x,int y)
    {
    int temp;
    temp =x;
    x=y;
    y=temp;
    }

    a)10, 20 b) 20, 12 c) 22, 10 d)10, 22 e)none
    Answer: d) 10, 22

    17. What is the output of the following problem?
    #define INC(X) X++
    main()
    {
    int X=4;
    printf("%d",INC(X++));
    }
    a) 4 b) 5 c) 6 d) compilation error e) runtime error
    Answer: d) compilation error

    18. What can be said of the following?
    struct Node {
    char *word;
    int count;
    struct Node left;
    struct Node right;
    }

    a) Incorrect definition
    b) Structures cannot refer to other structure
    c) Structures can refer to themselves. Hence the statement is OK
    d) Structures can refer to maximum of one other structure
    Answer :c)

    19. What is the size of the following union?
    Assume that the size of int =2, size of float =4 and size of char =1.
    Union Tag{
    int a;
    flaot b;
    char c;
    };

    a) 2 b) 4 c) 1 d) 7



    20) What is the output of the following program? (has been used to indicate a space)
    main()
    {
    char s[]="Hello,.world";
    printf(%15.10s",s);
    }

    a) Hello, World...
    b)....Hello,. or
    c) Hello,. or....
    d) None of the above
  3. 1. WAP finds and replaces a character in a string.

    2. WA functions to perform the subtraction of two.
    Egg: char N1="123", N2="478", N3=-355(N1-N2).

    3. WAP dynamically initialize a 2 dimensional array Eg: 5x20, accept strings and check for vowels and display the no. finally free the space allocated .

    4. WAP read a line from file from location N1 to N2 using command line arguments
    Eg: exe 10 20 a.c freshersworld.com

    5. WAP find the largest of 4 no using macros.


    1) HP acquired this company in 2002. Which is the company?
    a) Compaq
    b) Dell
    c) option 3
    d) Option4
    Ans: a

    2) what does 3G denote
    a) 3rd generation mobile communication
    b) 3rd generation computer languages
    c) option 3
    d) option4
    Ans: a

    3)an application program that is used by the users to get the information from the backend of some application like databases:
    a) Application server
    b)proxy server
    c)database server
    d)option 4
    Ans: database server freshersworld.com

    4) Which of the following is not true about the e-mail
    a) it can be accessed by a client program using POP
    b) it can be accessed by a client program using imp protocol
    c) Option 3
    d) Option 4
    Ans: I don't remember the answer but first 2 are true.

    5) What is X.25?
    a) option 1
    b)option 2
    c)option 3
    d)option 4
    Ans: find out??:)

    6)
    main( )
    {
    unsigned int i=3; freshersworld.com
    while( i >=0)
    printf( "%d", i--);
    }
    how many times will the printf stmt be executed?
    a)0
    b)3
    c)4
    d)infinite
    Ans: I think the answer is infinite, because 'i' is an unsigned integer and it will not decrement below '0' and hence end up in an infinite loop

    7) main( )
    {
    int x,y, z;
    x=2;
    y=5;
    z= x+++y;
    printf("%d %d %d", x, y z);
    }
    a)3 5 7
    b)option
    2 c)option
    3 d)option

    Ans: a

    8) # define swap(a,b) temp=a; a=b; b=temp;
    main( )
    { freshersworld.com
    int i, j, temp;
    i=5;
    j=10;
    temp=0;
    if( i > j)
    swap( i, j );
    printf( "%d %d %d", i, j, temp);
    }
    Ans: On compiling i got ans 10, 0, 0. I did not understand the concept. Please expalin this to me.

    9) Java was initially code named as:
    a) Oak
    b) green
    c) miller
    d)option4
    Ans: Oak

    10) What is not true about the following statements about java.
    a) It is compiled using java compiler
    b) The compiled files have .class extension.
    c) Such files cannot be transferred from one comp to another.
    d) They use the java interpreter freshersworld.com
    Ans: c

    11) Why is synchronize used?
    a) To initialize multiple objects
    b) To lock an object
    c) Option3
    d) Option 4
    Ans: b (probably)

    12) An application program that is used by the users to get the information from the backend of some application like databases:
    a) Application server
    b) Proxy server
    c) Database server
    d) System Server
    Ans: database server

    13) Which of the following is not a protocol?
    a) HTTP
    b) PIM
    c) PSI
    Ans: PSI (check)

    14) Which of the following does not help security.
    a) Good Password
    b) Update Antivirus
    c) VLAN
    Ans: VLAN

    15) What was the problem with Intel Processor?
    a) Cache
    b) PU
    c) NONE
    Ans: FIND OUT AND LET ME KNOW

    16) Which of the following is not a IM client
    a) AOL
    b) MSN
    c) JABBER
    d) XINGC
    Ans: XINGC

    17) Who is associated with HOTMAIL?
    a) SABEER Bhatia and Jack Smith
    b) SABEER Bhatia and Bill Gates

    Ans: SABEER Bhatia and Jack Smith

    18) Which of the following is not a application server
    a) BLUESTONE
    b) WEBSPHERE
    c) TOMCAT
    d) JBOSS
    Ans: BLUESTONE

    19) What do u call software embedded in ROM
    a) BIOS
    b) IRMWARE
    c) SHAREWARE
    d) FREEWARE
    Ans: BIOS (Verify)

    20) IP ADDRESS occupies
    a) 4 bytes
    b) 8 bytes
    c) 16 bytes
    d) 6 bytes
    Ans: 4 bytes

    21) Which Data Structure helps Searching?
    a) STACK
    b) LINKED LIST
    c) HASH
    Ans: HASH

    22) Q on Binary tree Depth?
    a) 2^n
    b) 2^n - 1
    c) log n


    23) Which of the following cannot be used across files?
    a) Extern
    b) Volatile
    c) static
    d) Const
    Ans: static

Share This Page