C++ Upwork Test

0
695

We don’t guarantee that all provided answers are correct.

Which symbol is used to declare the processor directives?
Answer

  • $
  • #
  • &
  • ^
  • ~
  • @

How do you invoke a base member function from a derived class in which you have overridden that function?
Answer

  • Base FunctionName(){}
  • Base::FunctionName();
  • Base functionName(void)
  • FunctionName();

Which of the following statements are correct?
Note: There may be more than one right answer.
Answer

  • A constructor of a derived class can access any public and protected member of the class
  • Constructor cannot be inherited but the derived class can call them
  • A constructed of a derived class cannot access any public or protected member of base class

What is the value held by a.x when the break point is reached?
union u {int x; double d; };
int main()
{
u a;
a.x=7;
a.d=7.7;
int y = a.x; // <= breakpoint placed here
}
Answer

  • unintialized
  • 7
  • 7.7
  • 14.7

How many members does the below freelancer class have?
class Upwork {public:
int freelancers;
int job;
int projects;
private:
double income;
double costs;
};

class project {public:
char*client;
char*title;
duble hours;
double rate;
private:
char*dialog;
char*ip;
};

class freelancer : Upwork, world, project {
private:
char* name;
};
Answer

  • 1
  • 8
  • 10
  • 11
  • 15

Which statement is incorrect?
Answer

  • The default value for an argument can be a global constant
  • The default arguments are given in the function prototype
  • Compiler uses the prototype information to build a call, not the function definition
  • The defalut arguments are given in the function prototype and should be repeated in the function definition

The stream ‘cout’ is by default connected to the console output______
Answer

  • object
  • class
  • device!
  • Hardware

Which operator is used to allocate memory?
Answer

  • +
  • new
  • =
  • free

Which of the following can use to pass an array object to a function?
Answer

  • void someFunction(Array[int]&);
  • void someFunction(Array&);
  • void someFunction(Array&));
  • void someFunction(Array &);

How many default constructor per class are possible?
Answer

  • 1
  • 2
  • 3
  • unlimited

Which of the following will compile, link and run ok in c++ ?(choose all that apply.)
Note: There may be more than right answer
Answer

  • struct B{};
    struct B1:B {};
    struct B2:B{};
    struct C();
    struct DO :B1, B2, private C{};
    int main{}
    {
    DD* p = new DD;
    }
  • Struct B{};
    struct B1:B{};
    struct B2:B{};
    struct C();
    struct DD: B1, B2, private C{};
    int main() {
    DD* p = new DD;
    B1* pb = p;
    }
  • struct B{};
    struct B1:B{};
    srtuct B2:B{};
    struct C{};
    struct DO :B1, B2, private C{};
    int main()
    {
    DD* p= new DD;
    B* pb= p;
    }
  • struct B{};
    struct B1:B{};
    struct B2:B{}
    struct C{};
    struct DD :B1, B2, private C{};
    int main() {
    DD* p = new DD;
    C* pb = p;
    }

Which statement is correct?
Answer

  • Two function having same no of argument, order and type of argument can be overloaded if both functions do not have any default argument
  • Overloaded function must have default arguments
  • Overloaded function must have default arguments starting from the left of argument list
  • A function may be overloaded more than once

C++ provides the ability to define ___ and ____ as its primary encapsulation mechanism.
Answer

  • Class, functions
  • Classes, object
  • Classes, variable
  • Classes, instance

What does a container adapter provides to interface?
Answer

  • Restricted interface
  • More interface
  • No interface
  • None of the above

What do the function objects implement?
Answer

  • operator
  • operator()
  • oprand
  • None of the above

Which of the following classes are supported in C++.
Answer

  • auto and static
  • extern
  • registered and multable
  • All of the above

When your program allocate on the free store, a ____ is returned.
Answer

  • delete
  • null
  • pointer!
  • bool

Copy constructor must receive its arguments by ______
Answer

  • either pass-by-value or pass-by-reference
  • only pass-by-value
  • only pass-by-reference
  • None of the above

How many types of templates are there in C++?
Answer

  • 1
  • 2
  • 3
  • 4

Which of the following is the correct way to declare function as constant?
Answer

  • int showData(void) const { }
  • func showData(void) const { }
  • const int showData(void) { } !
  • func const showData(void) { }

Which operator is used to deallocate the memory?
Answer

  • destroy
  • free
  • empty
  • None of the above

Destructor has the same name as constructor and it is preceded by ___ ?
Answer

  • !
  • &
  • $
  • ~

To which of class can we apply RITI?
Answer

  • Encapsulation
  • Polymorphic
  • Derived
  • None of the above

How can declare a template?
Answer

  • temp
  • tem
  • template<>
  • None of the above

Which function cannot overloaded?
Answer

  • Member Function
  • Static Function
  • Virtual Function
  • None of the above

Which operator is used to resolve the scope of the global variable?
Answer

  • –>
  • ::
  • ,
  • *!

Refrence is like a_____
Answer

  • Pointer
  • Structure
  • Macro
  • Enum

Destructor calls are made in which order of the corresponding constructor calls?
Answer

  • same order
  • Reverse order
  • Depends on how the object was constructed!
  • None of the order

What is template?
Answer

  • A template is a formula for creating a generic class
  • A template used to manipulate the class
  • A template is used for creating the attributes
  • None of the above

The pointer which stores the current active address is ____
Answer

  • this
  • *ptr
  • auto_ptr
  • None of the above

What is a function template ?
Answer

  • Creating a function without having to specify the exact type
  • Creating a functin with having an exact type
  • Both of the above
  • None of the above

How many object can be created from the object class?
Answer

  • 0
  • 1
  • 2
  • unlimited

Which type of data member can be shared by all instances of a class?
Answer

  • public
  • friend
  • static
  • inherited

An operator ‘___’ will allow you to delete memory allocated as an array which will ensure that every object in the aray will receive a destructor call.
Answer

  • destructor
  • delete
  • delete[]
  • kill[]
  • free[]
  • free[]
  • nuke[]

which function declaration are VALID? (choose all the apply)
Note:- There may be more than one right answer.
Answer

  • int upwork(int freelancer, int job=2,int project =3);
  • int upwork(int freelancer=5, int job, int project);
  • int upwork(int freelancer, int job, int projects=3);

Which of the following are minimal program in C++? (choose all that apply)
Answer

  • static int Main(string[] args) { return 0; }
  • int main() { }
  • int main(int argc, char* argv[]) { }
  • public static void main(String [ ] args) {}

36.consider the following C++ definitions:
int* x = 0;
which of the following expressions refers to the location of the variable x in memory?
Answer

  • x
  • x*
  • x&
  • *x
  • &x
  • &&x
  • **x
  • &x*

Which constructor function is designed to copy object of the same class type?
Answer

  • Create constructor
  • copy constructor
  • Object constructor
  • Dynamic constructor

Which of the following is not the member of class?
Answer

  • Staic function
  • Friend function
  • Const function
  • Virtual function

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.