Home / General Knowledge / Testing sawaal :: Programming Section 1

General Knowledge :: Testing sawaal

  1. main()

    {

    char *p; p = "Hello";

    printf ("%cn", *&*p);

    }

  2. A.
    H
    B.
    Hello
    C.
    Compilation error
    D.
    H E L L O

    View Answer

    Workspace

    Discuss Discuss in Forum


  3. What is the output of this C code?

       #include <stdio.h>
        int main()
        {
            int a = 1, b = 1;
            switch (a)
            {
            case a*b:
                printf("yes ");
            case a-b:
                printf("non");
                break;
            }
        }

  4. A.
    yes
    B.
    no
    C.
    Compile time error
    D.
    yes no

    View Answer

    Workspace

    Discuss Discuss in Forum


  5. main()

    {

    char s[ ] = "man";

    int i;

    for( i=0; s[ i ]; i++)

    printf( "n%c%c%c%c", s[ i ], *(s+i), *(i+s), i[s] );

    }

  6. A.
    mmmm aaaa nnnn
    B.
    aaaa mmmm nnnn
    C.
    nnnn aaaa mmmm
    D.
    None

    View Answer

    Workspace

    Discuss Discuss in Forum


  7. What will be output when you will execute following c code?

    #include <stdio.h>
    void main()

    {
        signed int a = -1;
        unsigned int b = -1u;
        if(a == b)
             printf( "The Lord of the Rings" );
        else
             printf( "American Beauty" );
    }

  8. A.
    The Lord of the Rings
    B.
    American Beauty
    C.
    Compilation error: Cannot compare signed number with unsigned number
    D.
    Warning: Illegal operation

    View Answer

    Workspace

    Discuss Discuss in Forum


  9. Which of the following is not a valid escape code?

  10. A.
    "
    B.
    \
    C.
    '
    D.
    =

    View Answer

    Workspace

    Discuss Discuss in Forum


  11. enum colors {BLACK,BLUE,GREEN}

    main()

    {

    printf( "%d..%d..%d", BLACK, BLUE, GREEN );

    return(1);

    }

  12. A.
    1..2..3
    B.
    0..1..2
    C.
    1..1..1
    D.
    0..0..0

    View Answer

    Workspace

    Discuss Discuss in Forum


  13. public abstract interface Frobnicate { public void twiddle(String s); } 

    Which is a correct class?

  14. A.
    public abstract class Frob implements Frobnicate { public abstract void twiddle(String s) { } }
    B.
    public abstract class Frob implements Frobnicate { }
    C.
    public class Frob extends Frobnicate { public void twiddle(Integer i) { } }
    D.
    public class Frob implements Frobnicate { public void twiddle(Integer i) { } }

    View Answer

    Workspace

    Discuss Discuss in Forum


  15. How many times i value is checked in the below code?

           #include <stdio.h>
            int main()
            {
                int i = 0;
                do {
                    i++;
                    printf( "In while loopn" );
                } while (i < 3);
            }

  16. A.
    2
    B.
    3
    C.
    4
    D.
    1

    View Answer

    Workspace

    Discuss Discuss in Forum


  17. Output of the Program :

    main()

    {

    int i = 1;

    while (i <= 5)

        {

             printf( "%d", i );

             if (i > 2) goto here;

             i++;

         }

    }

    fun()

    {

    here : printf( "PP" );

    }

  18. A.
    1
    B.
    2
    C.
    Compilation error
    D.
    Exception occurs

    View Answer

    Workspace

    Discuss Discuss in Forum


  19. What is the output of this C code?

           #include <stdio.h>
            void main()
            {
                int x = 1, z = 3;
                int y = x << 3;
                printf( "%dn", y );
            }

  20. A.
    -2147483648
    B.
    -1
    C.
    Run time error
    D.
    8

    View Answer

    Workspace

    Discuss Discuss in Forum