JOBSEEKERS
Login
Sign Up
Jobseeker
Employer
Staffing Firm
Direct Client
Object Oriented Programming interview questions part 4
Object Oriented Programming interview questions part 4
Back
Take as many assements as you can to improve your validate your skill rating
Total Questions: 20
1. If class B inherits class A privately. And class B has a friend function. Will the friend function be able to access the private member of class A?
A. Yes, because friend function can access all the members
B. Yes, because friend function is of class B
C. No, because friend function can only access private members of friend class
D. No, because friend function can access private member of class A also
Show Correct Answer
Correct Answer is :
No, because friend function can only access private members of friend class
2. If an abstract class has all the private members, then _________
A. No class will be able to implement members of abstract class
B. Only single inheritance class can implement its members
C. Only other enclosing classes will be able to implement those members
D. No class will be able to access those members but can implement.
Show Correct Answer
Correct Answer is :
No class will be able to implement members of abstract class
3. Which access specifier should be used so that all the parent class members can be inherited and accessed from outside the class?
A. Private
B. Default or public
C. Protected or private
D. Public
Show Correct Answer
Correct Answer is :
Public
4. Which access specifier is usually used for data members of a class?
A. Private
B. Default
C. Protected
D. Public
Show Correct Answer
Correct Answer is :
Private
5. Which specifier should be used for member functions of a class?
A. Private
B. Default
C. Protected
D. Public
Show Correct Answer
Correct Answer is :
Public
6. When value of an object is assigned to another object, ___________________
A. It becomes invalid statement
B. Its values gets copied into another object
C. Its values gets address of the existing values
D. The compiler doesn’t execute that statement
Show Correct Answer
Correct Answer is :
Its values gets copied into another object
7. If an object is created and another object is assigned to it, then ________________
A. Copy constructor is called to copy the values
B. Object is copied directly to the object
C. Reference to another object is created
D. The new object is initialized to null values
Show Correct Answer
Correct Answer is :
Reference to another object is created
8. How the argument passed to a function get initialized?
A. Assigned using copy constructor at time of passing
B. Copied directly
C. Uses addresses always
D. Doesn’t get initialized
Show Correct Answer
Correct Answer is :
Assigned using copy constructor at time of passing
9. Predict the output of the program. class A { public int i; }; void main() { A x; A y=x; x.i=10; y.i=20; y.i++; y.i=20; cout&l;<tx.i; }
A. 10
B. 20
C. 21
D. 0
Show Correct Answer
Correct Answer is :
20
10. If programmer doesn’t define any copy assignment operator then ____________________
A. Compiler gives an error
B. Program fails at run time
C. Compiler gives an implicit definition
D. Compiler can’t copy the member values
Show Correct Answer
Correct Answer is :
Compiler gives an implicit definition
11. Declaring a copy constructor doesn’t suppresses the compiler generated copy assignment operator.
A. TRUE
B. FALSE
C.
D.
Show Correct Answer
Correct Answer is :
TRUE
12. In copy constructor definition, if non const values are accepted only ________
A. Only const objects will be accepted
B. Only non – const objects are accepted
C. Only const members will not get copied
D. Compiler generates an error
Show Correct Answer
Correct Answer is :
Only non – const objects are accepted
13. How many objects can be assigned to a single address?
A. Only 1
B. At most 7
C. At most 3
D. As many as required
Show Correct Answer
Correct Answer is :
As many as required
14. Use of assignment operator ____________________
A. Changes its use, when used at declaration and in normal assignment
B. Doesn’t changes its use, whatever the syntax might be
C. Assignment takes place in declaration and assignment syntax
D. Doesn’t work in normal syntax, but only with declaration
Show Correct Answer
Correct Answer is :
Changes its use, when used at declaration and in normal assignment
15. If more than one object refer to the same address, any changes made
A. Can be made visible to specific objects
B. Will be specific to one object only
C. From any object will be visible in all
D. Doesn’t changes the values of all objects
Show Correct Answer
Correct Answer is :
From any object will be visible in all
16. How to make more than one object refer to the same object?
A. Initialize it to null
B. Initialize the object with another at declaration
C. Use constructor to create new object
D. Assign the address directly
Show Correct Answer
Correct Answer is :
Initialize the object with another at declaration
17. We can assign ______________________
A. Value of one reference variable to another
B. Value of any object to another
C. Value of any type to any object
D. Value of non – reference to another reference
Show Correct Answer
Correct Answer is :
Value of one reference variable to another
18. Assigning reference to an object _________________
A. Will create another copy of the object
B. Will create two different copies of the object
C. Will not create any other copy of the object
D. Will not refer to the object
Show Correct Answer
Correct Answer is :
Will not create any other copy of the object
19. Which among the following is true?
A. We can use direct assignment for any object
B. We can use direct assignment only for different class objects
C. We must not use direct assignment
D. We can use direct assignment to same class objects
Show Correct Answer
Correct Answer is :
We can use direct assignment to same class objects
20. Assigning objects takes place while passing the arguments.
A. TRUE
B. FALSE
C.
D.
Show Correct Answer
Correct Answer is :
FALSE
Similar Interview Questions
Search for latest jobs
Find Jobs