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

General Knowledge :: Testing sawaal

  1. Which of the following statement is true?

  2. A.
    Cohesion is the OO principle most closely associated with hiding implementation details
    B.
    Cohesion is the OO principle most closely associated with making sure that classes know about other classes only through their APIs
    C.
    Cohesion is the OO principle most closely associated with making sure that a class is designed with a single, well-focused purpose
    D.
    None

  3. What will be output of the following c program ?

    #include

    int main()

    {

        int max-val=100;

        int min-val=10;

        int avg-val;

        avg-val =( max-val + min-val ) / 2;

        printf( "%d", avg-val );

        return 0;

    }

  4. A.
    55
    B.
    105
    C.
    60
    D.
    Compilation error

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

    #include <stdio.h>
    void main()

    {
        int const SIZE = 5;
        int expr;
        double value[SIZE] = { 2.0, 4.0, 6.0, 8.0, 10.0 };
        expr=1|2|3|4;
        printf ( "%f", value[expr] );
    }

  6. A.
    2.000000
    B.
    4.000000
    C.
    8.000000
    D.
    Compilation error

  7. Which Of The Following Statements Is Most Accurate For The Declaration X = Circle()?

  8. A.
    x contains a reference to a Circle object
    B.
    You can assign an int value to x
    C.
    x contains an object of the Circle type
    D.
    x contains an int value

  9. What will be output of following program ?

    #include
    int main()

    {

    int a = 10;
    void *p = &a;
    int *ptr = p;
    printf("%u",*ptr);
    return 0;

    }

  10. A.
    10
    B.
    Address
    C.
    2
    D.
    Compilation error

  11. What would be the output of the following program ?

    main()

    {

         const int x = 5; 

          int *ptrx;

          ptrx = &x;

          *ptr = 10;

           printf ("%d", x);

    }

  12. A.
    5
    B.
    10
    C.
    Error
    D.
    Garbage value

  13. What will output when you compile and run the following code?

    #include <stdio.h>
    struct student
    {

    int roll;
    int cgpa;
    int sgpa[8];

    };

    void main()
    {

    struct student s = { 12,8,7,2,5,9 };
    int *ptr;
    ptr = (int *)&s;
    clrscr();
    printf( "%d", *(ptr+3) );
    getch();

    }

  14. A.
    8
    B.
    7
    C.
    2
    D.
    Compiler error

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

    #include <stdio.h>
    void main()

    {
         switch(2)

          {
                case 1L:printf("No");
                case 2L:printf("%s","I");
                  goto Love;
                case 3L:printf("Please");
                case 4L:Love:printf("Hi");
         }
    }

  16. A.
    I
    B.
    IPleaseHi
    C.
    IHi
    D.
    Compilation error

  17. If the following program (myprog) is run from the command line as 

    myprog 1 2 3 

    what would be the output?

    main(int argc, char *argv[])

    {

        int i, j = 0;

        for (i = 0; i < argc ; i++)

               j = j + atoi ( argv[i]);

        printf ("%d", j);

    }

  18. A.
    123
    B.
    6
    C.
    Error
    D.
    "123"

  19. What will be output of following program?


    #include <stdio.h>
    int main()

    {
       void (*p)();
       int (*q)();
       int (*r)();
       p = clrscr;
       q = getch;
       r = puts;
      (*p)();
      (*r)("www.sawaal.com");
      (*q)();
      return 0;
    }

  20. A.
    NULL
    B.
    www.sawaal.com
    C.
    Compilation error
    D.
    None of above