If you have “int main(int argc, char* argv[])” and invoke your program this way: prog.exe a.out -i 2 -g -x 3 4 What will be the value of argc?

  • Other
  • I don’t know
  • a.out
  • 7
  • 3
  • 2
  • 0

If n=3, what will be the result of:
switch(n)
{
case '3':
cout << "wow \n";
break;
case 3:
cout << "bab \n";
break;
default:
cout << "heh \n";
break;
}

  • wow
  • Undefined behaviour
  • I don’t know
  • heh
  • Compiler error
  • bab

Which header file you should include for C++ file I/O?

  • Other
  • iostream
  • ifstream
  • I don’t know
  • fstream
  • fileio

What is the default access permission for members in a class?

  • public
  • protected
  • private
  • I don’t know

What is the default access permission for members in a struct?

  • public
  • protected
  • private
  • I don’t know

    What will be the result of:

    int f(int a) { return ++a; }
    int f(unsigned int a) { return --a; }
    cout << f(5);

    • Undefined behaviour
    • I don’t know
    • Compiler error
    • 6
    • 5
    • 4

    What will !((1 || 0) && 0) evaluate to?

    • Wrong code
    • Undefined behaviour
    • I don’t know
    • 1
    • 0

    If i = 5, what will be the result of:

    do
    {
    cout << (--i)-- << " ";
    } while(i>=2 && i < 5);

    • It won’t enter the loop
    • It will loop forever
    • I don’t know
    • Compiler error
    • 4 3 2 1
    • 4 3 2
    • 4 2 1
    • 4 2

    What will be the result after running this code:

    for(int i=0;i<3;i++)
    {
    cout << i << " ";
    continue;
    cout << 7 << " ";
    break;
    for(int j=0;j<1;j++)
    cout << 5 << " ";
    }

    • None of these
    • I don’t know
    • 0 7 5 1 7 5 2 7 5
    • 0 7 1 7 2 7
    • 0 1 2

    What will be printed on the screen after running:

    int x=65, *p = &x;
    cout << p << "__" << *p ;

    • Program will crash
    • Other
    • MemoryAddress_65
    • I don’t know
    • Compiler error
    • 65_MemoryAddress

    In which header file is the function isalpha()?

    • string.h
    • Other
    • ifstream.h
    • I don’t know
    • ctype.h
    • conio.h

    Which one is correct?

    • int a; a = new sizeof(int*20);
    • int a; a = new int[20];
    • int a; a = new int(20);
    • int *a; a = new sizeof(int*20);
    • int *a; a = new int[20];
    • int *a; a = new 20;
    • I don’t know

    How do you access the last cell of “int arr[123];”?

    • Other
    • I don’t know
    • arr[124]…
    • arr[123]…
    • arr[122]…

    May the main() function be overloaded?

    • Yes
    • No
    • I don’t know

    If we have:

    int f(int x)
    {
    if(x>2)
    return x + f(--x);
    else
    return 0;
    }

    What will be the resulf of: cout << f(5);

    • Program will freeze
    • Other
    • I don’t know
    • 6
    • 12
    • 10
    • 0

    If Foo is a member function of a class, which of the following uses of const is legal?

    • void Foo(Squid& a) const;
    • void Foo(const Squid& a);
    • void Foo(const Squid& a) const;
    • None of the above
    • const void Foo(const Squid& a) const;
    • All of the above
    • I don’t know

    If Foo is a static function in a class, which of the following uses of const is legal?

    • void Foo(Squid& const a);
    • void Foo(const Squid& a);
    • void const Foo(Squid& a);
    • void (Squid& a) const;
    • I don’t know

    Is it possible that a class does not have a name?

    • Yes, but you can’t have objects from it
    • Yes, and you can have objects from it
    • No
    • I don’t know

    If we have this code:

    char arr[8];
    cin >> arr;

    And this text is entered: “Hello World”, what there will be in “arr”?

    • Other
    • I don’t know
    • Hello World
    • Hello Wo
    • Hello W
    • Hello

    If we have this code:

    class A
    {
    public:
    A() { cout << 1; }
    ~A() { cout << 2; }
    };

    class B : public A
    {
    public:
    B() { cout << 3; }
    ~B() { cout << 4; }
    };

    And we create an object from class B, what will be the result?

    • Other
    • I don’t know
    • 3412
    • 3142
    • 3124
    • 1342
    • 1324
    • 1234

    What will be the result of: cout << (5 << 3); ?

    • I don’t know
    • Compiler error
    • 53
    • 40
    • 35

    What will be the result of: cout << 22/5*3; ?

    • Other
    • I don’t know
    • 13.2
    • 12
    • 1.47
    • 1

    Which keyword specifies that an integer variable can not take negative values?

    • unsigned
    • There is not such a keyword
    • positive
    • Other
    • long
    • I don’t know

    If we have: char a; , which one is incorrect?

    • I don’t know
    • All are correct
    • a = 3;
    • a = ‘3′;
    • a = “3″;

    What will happen if we have this code:

    char a[3] = {’d',’w',’\0′};
    char b[3];
    b = a;

    • Other
    • I don’t know
    • Compiler error
    • “b” will be unchanged
    • “b” will be the same as “a”

    Is this code legal?
    int a; int b[a];

    • Yes
    • No
    • I don’t know

    If we have:

    int a=9; //in the global space...
    void f() { int a; a = 4; }

    And if we type: cout << a; in the main() function, what will be the result?

    • Other
    • I don’t know
    • 9
    • 4
    • 0

    If we have this code:

    class A { public: int a; };
    A *obj;

    How do we access the “a” variable?

    • obj::a
    • obj.a
    • obj-a
    • obj->a
    • I don’t know

    Which of these has the highest precedence?

    • I don’t know
    • /
    • ++
    • +
    • *
    • ()

    What should you do to free the memory after running this code?

    char *a; a = new char[20];

    • I don’t know
    • delete [] a;
    • delete a[];
    • delete a;

  • Leave a Reply

    You must be logged in to post a comment.