More C++ placement model paper
1. Following is the not a correct statement for preprocessor directive declaration?
a) #include<iostream.h>
b) #include<iostream.h> #define LEFT 1
c) #define LEFT 1
d) #define ABS(a) (a)<0 ? –(a) : (a)
View Answer / Hide AnswerANSWER: b) #include<iostream.h> #define LEFT 1
2. In C++ if return statements is written in a non-void function without any specified value, what will be return value of the function?
a) undefined
b) 1
c) 0
d) -1
View Answer / Hide Answer 3. In C++ how many return statements are allowed in a non-void function?
a) 1
b) as many as you like
c) 0
d) 2
View Answer / Hide AnswerANSWER: b) as many as you like
4. In C++ if program executed successfully, following value will be returned to the calling process, if nothing specified in return statement?
a) 0
b) 1
c) -1
d) 2
View Answer / Hide Answer5. Individual characters in a string are accessed as following
a) cout << S.at(i);
b) cout << S[i];
c) both a) and b)
d) None
View Answer / Hide AnswerANSWER: c) both a) and b)
6. Which of the following keyword is not used in exception handling
a) Try
b) allow
c) Catch
d) Throw
View Answer / Hide Answer7. We can throw exception in catch block
a)True
b)false
View Answer / Hide Answer8. Which of the following is invalid header file name?
a) <iostring>
b) <string>
c) <iostream >
d) <sstream>
View Answer / Hide Answer9. Following is not the correct syntax for exception handling
a) Type function (arg-list) throw(type-list)
{
}
b) Try (type-list)
{
}
Catch(type arg)
{
}
c) Try
{
_____
throw;
}
Catch(type arg)
{
Throw;
}
d) Try
{
_____
throw;
}
Catch(type arg)
{
Throw(exception);
}
Catch(type arg)
{
Throw;
}
View Answer / Hide Answer10. You can use C++ as a procedural, as well as an object-oriented language?
a) true
b) false
View Answer / Hide Answer11. Inheriting a derived class from a base class needs vital changes to the base class?
a) true
b) false
View Answer / Hide Answer12. The pow functions returns _____:
a) int
b) double
c) string
d) float
View Answer / Hide Answer13. In the following statements,
class sports {};
class test : public student{};
class result : public test, public sports {};
//Here result class have implemented,
a) Hierarchical inheritance
b) Multiple inheritance
c) Multilevel inheritance
d) Both b) and c)
View Answer / Hide AnswerANSWER: d) Both b) and c)
14. Which of the following are valid array declaration
a) int num(5)
b) float avg[5]
c) double[5] marks
d) counter int[5]
View Answer / Hide Answer 15. Which of the following are valid array declaration
a) char str1[3] = “ab”
b) char str1[3] = “abc”
c) char str1[2] = “ab”
d) char str1[0] = “ab”
View Answer / Hide AnswerANSWER: a) char str1[3] = “ab”
16. C++ supports ….
a) constant pointer
b) pointer to a constant
c) None of above
d) Both of above
View Answer / Hide Answer17. char * const ptr1 = “nice”;
//this is example of ,
a) constant pointer
b) pointer to a constant
c) None of above
d) Both of above
View Answer / Hide AnswerANSWER: a) constant pointer
18. int const *ptr1 = &m;
// this is example of,
a) Constant pointer
b) Pointer to a constant
c) Both of above
d) None of above
View Answer / Hide AnswerANSWER: b) Pointer to a constant
19. In the following statement,
const char * const cp = “xyz”;
a) Address assigned to pointer cp cannot be changed
b) contents it points to cannot be changed
c) Both of above
d) None of above
View Answer / Hide Answer20. In C++, symbolic constants created using
a) const
b) enum
c) Both of above
d) None of above
View Answer / Hide Answer21. A friend class in C++, can access the "__________" members of the class in which it is declared as a friend
a) private and protected
b) private and public
c) public and protected
d) Public
View Answer / Hide AnswerANSWER: a) private and protected
22. A friend function that is a "friend" of a given class is allowed access to ______data in that class.
a) public, private, or protected
b) public or private
c) public
d) protected
View Answer / Hide AnswerANSWER: a) public, private, or protected
23. Object can be used as a function argument by..
a) Pass by value
b) Pass by reference
c) None of above
d) All of above
View Answer / Hide Answer24. In the following statements,
class X
{
int fun1 ();
};
class Y
{
friend int X :: fun1 ();
};
a) Function fun1() is member of class Y and friend of class X.
b) Function fun1() is member of class X and friend of class Y.
c) Function fun1() is member of class X and friend of class X.
d) Function fun1() is member of class Y and friend of class Y.
View Answer / Hide AnswerANSWER: b) Function fun1() is member of class X and friend of class Y.
25. In the following statements,
class Z
{
friend class X;
};
a) All member function Z of are friend to X
b) All member function of X are friend to Z
c) All member function of X are friend to X
d) All member function of Z are friend to Z
View Answer / Hide AnswerANSWER: b) All member function of X are friend to Z
26. In the following statements,
class ABC;
class ABC
{
};
a) It is called as forward declaration
b) It is called as backward declaration
c) It is called as middle declaration
d) It is called as simple declaration
View Answer / Hide AnswerANSWER: a) It is called as forward declaration
27. Member function of one class can be friend function of another class
a) true
b) false
View Answer / Hide Answer28. All member function of one class can be declared as friend function of another class, is called as
a) friend class
b) neighbor class
c) sister class
d) inherited class
View Answer / Hide Answer29. in C++, an object can be returned as argument
a) false
b) true
View Answer / Hide Answer30. Following is the dereferencing operator
a) ?::
b) &*
c) ->>
d) ->*
View Answer / Hide Answer31. Inventor of C++ language is
a) John Dell
b) Bjarne Stroustrup
c) Thomusn Steve
d) Karl Thomus
View Answer / Hide AnswerANSWER: b) Bjarne Stroustrup
32. Destructor can have following number of argument
a) 2
b) 1
c) 0
View Answer / Hide Answer33. While executing a program we first need to translate the source code into object code, it is called as
a) debugging
b) executing
c) compiling
View Answer / Hide Answer34. Array elements are accessed using
a) ::
b) .
c) ->
d) Index number
View Answer / Hide Answer35. Following operator cannot be used for operator overloading
a) +
b) ==
c) sizeof
View Answer / Hide Answer36. A function that is called automatically when an object is created is called as
a) constant
b) constructor
c) static
d) friend
View Answer / Hide Answer37. The null character will take space of
a) 0 byte
b) 2 byte
c) 1 byte
d) 8 byte
View Answer / Hide Answer38. This operator is used to allocate memory
a) new
b) delete
c) static
d) real
View Answer / Hide Answer