C++ Programming Questions Useful for all Companies Interviews, UGC-NET, GATE EXAM PART- 1
1. How any types of linkage are there in c++? a) 1 b) 2 c) 3 d) 4 View Answer Answer:c 2. To use internal linkage we have to use which keyword? a) static b) extern c) static or extern d) none of the mentioned View Answer Answer:a
3. Which one is used to refer to program elements in any translation units? a) internal linkage b) external linkage c) no linkage d) none of the mentioned View Answer Answer:b . What is the defualt type oof linkage that are available for identifires? a) internal b) external c) no linkage d) none of the mentioned View Answer Answer:b
. Pick out the other definition of objects. a) member of the class b) associate of the class c) attribute of the class d) instance of the class View Answer Answer:d Explanation:None. 7. How many objects can present in a single class? a) 1 b) 2 c) 3 d) as many as possible View Answer Answer:d
To use external linkage we have to use which keyword? a) static b) extern c) const d) none of the mentioned View Answer Answer:b Explanation:extern keyword is used to represent identifiers from other programs. 7. Which is used to use a function from one source file to another? a) code b) declaration c) prototype d) none of the mentioned View Answer Answer:c
Which is used to define the member of a class externally? a) : b) :: c) # d) none of the mentioned View Answer Answer:b Explanation:None. 4. Which other keywords are also used to declare the class other than class? a) struct b) union c) object d) both a & b View Answer Answer:d
8. What is the use of no linkage? a) make the entity visible to other programs b) make the entity visible to other blocks in the same program. c) make the entity visible only to that block d) none of the mentioned View Answer Answer:c Which of these following members are not accessed by using direct member access operator? a) public b) private c) protected d) Both b & c View Answer Answer:d
7. Which of the following is a valid class declaration? a) class A { int x; }; b) class B { } c) public class A { } d) object A { int x; }; View Answer Answer:a Explanation:None. 8. The fields in the class in c++ program are by default a) protected b) private c) public d) none of the mentioned View Answer Answer:b
. Where does the object is created? a) class b) constructor c) destructor d) attributes View Answer Answer:a Explanation:In class only all the listed items except class will be declared. 2. How to access the object in the class? a) scope resolution operator b) ternary operator c) direct member access operator d) none of the mentioned View Answer Answer:c
. What does your class can hold? a) data b) functions c) both a & b d) none of the mentioned View Answer Answer:C Explanation:The classes in c++ are used to manipulate both data and functions. 2. How many specifiers are present in access specifiers in class? a) 1 b) 2 c) 3 d) 4 View Answer Answer:c
Explanation:None. 9. Constructors are used to a) initalize the objects b) construct the data members c) both a & b d) none of the mentioned View Answer Answer:a Explanation:Once the object is declared means, the constructor are also declared by default. 10. When struct is used instead of the keyword class means, what will happen in the program? a) access is public by default b) access is private by default c) access is protected by default d) none of the mentioned View Answer Answer:a
What is the output of this program? 1.#include <iostream> 2.using namespace std; 3.int main() 4.{ 5.int i; 6.enum month { 7.JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,DEC 8.}; 9.for (i = JAN; i <= DEC; i++) 10.cout << i; 11.return 0; 12.} a) 012345678910 b) 0123456789 c) 01234567891011 d) none of the mentioned View Answer Answer:a
. Which keyword is used to define the user defined data types? a) def b) union c) typedef d) type View Answer Answer:c Explanation:None. 2. Identify the correct statement. a) typedef does not create different types.It only creates synonyms of existing types. b) typedef create different types. c) both a & b d) none of the mentioned View Answer Answer:a
7. What is the syntax of user-defined data types? a) typedef_existing data type_new name b) typedef_new name_existing data type c) def_existing data type_new name d) none of the mentioned View Answer Answer:a Explanation:None. 8. How many types of user-defined data type are in c++? a) 1 b) 2 c) 3 d) 4 View Answer Answer:c
What is the scope of typedef defined data types? a) inside that block only b) whole program c) outside the program d) none of the mentioned View Answer Answer:b Explanation:We are defining the user-defined data type to be availed only inside that program, if we want to use anywhere means we have to define those types in the header file. 10. How many types of models are available to create the user-defined data type? a) 1 b) 2 c) 3 d) 4 View Answer Answer:b
. Pick the other name of operator function. a) function overloading b) operator overloading c) member overloading d) None of the mentioned View Answer Answer:b Explanation:None. 2. Which of the following operators can’t be overloaded? a) :: b) + c) – d) [] View Answer Answer:a
. How to declare operator function? a) operator operator sign b) operator c) operator sign d) None of the mentioned View Answer Answer:a How many real types are there in complex numbers? a) 1 b) 2 c) 3 d) 4 View Answer Answer:c
. Which of the following statements is NOT valid about operator overloading? a) Only existing operators can be overloaded. b) Overloaded operator must have at least one operand of its class type. c) The overloaded operators follow the syntax rules of the original operator. d) None of the mentioned View Answer Answer:d Explanation:None. 9. Operator overloading is a) making c++ operator works with objects b) giving new meaning to existing operator c) making new operator d) both a & b View Answer Answer:d
. Which header file is used to declare the complex number? a) complexnum b) complex c) complexnumber d) None of the mentioned View Answer Answer:b Explanation:None. 2. How to declare the complex number? a) (3,4) b) complex(3,4) c) (3,4i) d) None of the mentioned View Answer Answer:b
Which of the following is not a function of complex values? a) real b) imag c) norm d) cartesian View Answer Answer:d How many parameters does a conversion operator may take? a) 0 b) 1 c) 2 d) as many as possible View Answer Answer:a
1. What is the return type of the conversion operator? a) void b) int c) float d) no return type View Answer Answer:d Explanation:Conversion operator doesn’t have any return type not even void. 2. Why we use the “dynamic_cast” type conversion? a) result of the type conversion is a valid b) to be used in low memory c) result of the type conversion is a invalid d) None of the mentioned View Answer Answer:a
. How types are there in user defined conversion? a) 1 b) 2 c) 3 d) 4 View Answer Answer:b Explanation:There are two types of user- defined conversions.They are conversion by constructor, Conversion functions. 10. Pick out the correct syntax of operator conversion. a) operator float()const b) operator float() c) operator const d) None of the mentioned View Answer Answer:a
Which rule will not affect the friend function? a) private and protected members of a class cannot be accessed from outside b) private and protected member can be accessed anywhere c) both a & b d) None of the mentioned View Answer Answer:a Explanation:Friend is used to access private and protected members of a class from outside the same class. 2. Which keyword is used to declare the friend function? a) firend b) friend c) classfriend d) myfriend View Answer Answer:b
3. What is the syntax of friend function? a) friend class1 Class2; b) friend class; c) friend class d) None of the mentioned View Answer Answer:a 3. What will happen when the function call operator is overloaded? a) It will not modify the functions. b) It will modify the functions. c) It will modify the object. d) It will modify the operator to be interpreted. View Answer Answer:d
9. Pick out the correct statement. a) A friend function may be a member of another class. b) A friend function may not be a member of another class. c) A friend function may or may not be a member of another class. d) None of the mentioned View Answer Answer:c Explanation:None. 10. Where does keyword ‘friend’ should be placed? a) function declaration b) function definition c) main function d) None of the mentioned View Answer Answer:a
. What is the use of function call operator? a) overloading the methods b) overloading the objects c) overloading the parameters d) none of the mentioned View Answer Answer:b Explanation:None. 2. Pick out the correct statement. a) virtual functions does not give the ability to write a templated function. b) virtual functions does not give the ability to rewrite a templated function. c) virtual functions does give the ability to write a templated function. d) none of the mentioned View Answer Answer:a

PART - 1 Cpp programming Solved MCQ

  • 1.
    C++ Programming Questions Usefulfor all Companies Interviews, UGC-NET, GATE EXAM PART- 1
  • 2.
    1. How anytypes of linkage are there in c++? a) 1 b) 2 c) 3 d) 4 View Answer Answer:c 2. To use internal linkage we have to use which keyword? a) static b) extern c) static or extern d) none of the mentioned View Answer Answer:a
  • 3.
    3. Which oneis used to refer to program elements in any translation units? a) internal linkage b) external linkage c) no linkage d) none of the mentioned View Answer Answer:b . What is the defualt type oof linkage that are available for identifires? a) internal b) external c) no linkage d) none of the mentioned View Answer Answer:b
  • 4.
    . Pick outthe other definition of objects. a) member of the class b) associate of the class c) attribute of the class d) instance of the class View Answer Answer:d Explanation:None. 7. How many objects can present in a single class? a) 1 b) 2 c) 3 d) as many as possible View Answer Answer:d
  • 5.
    To use externallinkage we have to use which keyword? a) static b) extern c) const d) none of the mentioned View Answer Answer:b Explanation:extern keyword is used to represent identifiers from other programs. 7. Which is used to use a function from one source file to another? a) code b) declaration c) prototype d) none of the mentioned View Answer Answer:c
  • 6.
    Which is usedto define the member of a class externally? a) : b) :: c) # d) none of the mentioned View Answer Answer:b Explanation:None. 4. Which other keywords are also used to declare the class other than class? a) struct b) union c) object d) both a & b View Answer Answer:d
  • 7.
    8. What isthe use of no linkage? a) make the entity visible to other programs b) make the entity visible to other blocks in the same program. c) make the entity visible only to that block d) none of the mentioned View Answer Answer:c Which of these following members are not accessed by using direct member access operator? a) public b) private c) protected d) Both b & c View Answer Answer:d
  • 8.
    7. Which ofthe following is a valid class declaration? a) class A { int x; }; b) class B { } c) public class A { } d) object A { int x; }; View Answer Answer:a Explanation:None. 8. The fields in the class in c++ program are by default a) protected b) private c) public d) none of the mentioned View Answer Answer:b
  • 9.
    . Where doesthe object is created? a) class b) constructor c) destructor d) attributes View Answer Answer:a Explanation:In class only all the listed items except class will be declared. 2. How to access the object in the class? a) scope resolution operator b) ternary operator c) direct member access operator d) none of the mentioned View Answer Answer:c
  • 10.
    . What doesyour class can hold? a) data b) functions c) both a & b d) none of the mentioned View Answer Answer:C Explanation:The classes in c++ are used to manipulate both data and functions. 2. How many specifiers are present in access specifiers in class? a) 1 b) 2 c) 3 d) 4 View Answer Answer:c
  • 11.
    Explanation:None. 9. Constructors areused to a) initalize the objects b) construct the data members c) both a & b d) none of the mentioned View Answer Answer:a Explanation:Once the object is declared means, the constructor are also declared by default. 10. When struct is used instead of the keyword class means, what will happen in the program? a) access is public by default b) access is private by default c) access is protected by default d) none of the mentioned View Answer Answer:a
  • 12.
    What is theoutput of this program? 1.#include <iostream> 2.using namespace std; 3.int main() 4.{ 5.int i; 6.enum month { 7.JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,DEC 8.}; 9.for (i = JAN; i <= DEC; i++) 10.cout << i; 11.return 0; 12.} a) 012345678910 b) 0123456789 c) 01234567891011 d) none of the mentioned View Answer Answer:a
  • 13.
    . Which keywordis used to define the user defined data types? a) def b) union c) typedef d) type View Answer Answer:c Explanation:None. 2. Identify the correct statement. a) typedef does not create different types.It only creates synonyms of existing types. b) typedef create different types. c) both a & b d) none of the mentioned View Answer Answer:a
  • 14.
    7. What isthe syntax of user-defined data types? a) typedef_existing data type_new name b) typedef_new name_existing data type c) def_existing data type_new name d) none of the mentioned View Answer Answer:a Explanation:None. 8. How many types of user-defined data type are in c++? a) 1 b) 2 c) 3 d) 4 View Answer Answer:c
  • 15.
    What is thescope of typedef defined data types? a) inside that block only b) whole program c) outside the program d) none of the mentioned View Answer Answer:b Explanation:We are defining the user-defined data type to be availed only inside that program, if we want to use anywhere means we have to define those types in the header file. 10. How many types of models are available to create the user-defined data type? a) 1 b) 2 c) 3 d) 4 View Answer Answer:b
  • 16.
    . Pick theother name of operator function. a) function overloading b) operator overloading c) member overloading d) None of the mentioned View Answer Answer:b Explanation:None. 2. Which of the following operators can’t be overloaded? a) :: b) + c) – d) [] View Answer Answer:a
  • 17.
    . How todeclare operator function? a) operator operator sign b) operator c) operator sign d) None of the mentioned View Answer Answer:a How many real types are there in complex numbers? a) 1 b) 2 c) 3 d) 4 View Answer Answer:c
  • 18.
    . Which ofthe following statements is NOT valid about operator overloading? a) Only existing operators can be overloaded. b) Overloaded operator must have at least one operand of its class type. c) The overloaded operators follow the syntax rules of the original operator. d) None of the mentioned View Answer Answer:d Explanation:None. 9. Operator overloading is a) making c++ operator works with objects b) giving new meaning to existing operator c) making new operator d) both a & b View Answer Answer:d
  • 19.
    . Which headerfile is used to declare the complex number? a) complexnum b) complex c) complexnumber d) None of the mentioned View Answer Answer:b Explanation:None. 2. How to declare the complex number? a) (3,4) b) complex(3,4) c) (3,4i) d) None of the mentioned View Answer Answer:b
  • 20.
    Which of thefollowing is not a function of complex values? a) real b) imag c) norm d) cartesian View Answer Answer:d How many parameters does a conversion operator may take? a) 0 b) 1 c) 2 d) as many as possible View Answer Answer:a
  • 21.
    1. What isthe return type of the conversion operator? a) void b) int c) float d) no return type View Answer Answer:d Explanation:Conversion operator doesn’t have any return type not even void. 2. Why we use the “dynamic_cast” type conversion? a) result of the type conversion is a valid b) to be used in low memory c) result of the type conversion is a invalid d) None of the mentioned View Answer Answer:a
  • 22.
    . How typesare there in user defined conversion? a) 1 b) 2 c) 3 d) 4 View Answer Answer:b Explanation:There are two types of user- defined conversions.They are conversion by constructor, Conversion functions. 10. Pick out the correct syntax of operator conversion. a) operator float()const b) operator float() c) operator const d) None of the mentioned View Answer Answer:a
  • 23.
    Which rule willnot affect the friend function? a) private and protected members of a class cannot be accessed from outside b) private and protected member can be accessed anywhere c) both a & b d) None of the mentioned View Answer Answer:a Explanation:Friend is used to access private and protected members of a class from outside the same class. 2. Which keyword is used to declare the friend function? a) firend b) friend c) classfriend d) myfriend View Answer Answer:b
  • 24.
    3. What isthe syntax of friend function? a) friend class1 Class2; b) friend class; c) friend class d) None of the mentioned View Answer Answer:a 3. What will happen when the function call operator is overloaded? a) It will not modify the functions. b) It will modify the functions. c) It will modify the object. d) It will modify the operator to be interpreted. View Answer Answer:d
  • 25.
    9. Pick outthe correct statement. a) A friend function may be a member of another class. b) A friend function may not be a member of another class. c) A friend function may or may not be a member of another class. d) None of the mentioned View Answer Answer:c Explanation:None. 10. Where does keyword ‘friend’ should be placed? a) function declaration b) function definition c) main function d) None of the mentioned View Answer Answer:a
  • 26.
    . What isthe use of function call operator? a) overloading the methods b) overloading the objects c) overloading the parameters d) none of the mentioned View Answer Answer:b Explanation:None. 2. Pick out the correct statement. a) virtual functions does not give the ability to write a templated function. b) virtual functions does not give the ability to rewrite a templated function. c) virtual functions does give the ability to write a templated function. d) none of the mentioned View Answer Answer:a