Object Oriented Programming interview questions part 16

Object Oriented Programming interview questions part 16

Take as many assements as you can to improve your validate your skill rating

Total Questions: 20

1. Java supports direct downcasting.

Correct Answer is : FALSE

2. Which way the downcasting is possible with respect to inheritance?

Correct Answer is : Downward the inheritance order

3. What happens when downcasting is done but not explicitly defined in syntax?

Correct Answer is : Compile time error

4. When is downcating used?

Correct Answer is : To compare two objects

5. Why is downcasting possible in any language?

Correct Answer is : Because inheritance follows is-a relationship

6. Which among the following best describes encapsulation?

Correct Answer is : It is a way of combining various data members and member functions that operate on those data members into a single unit

7. If data members are private, what can we do to access them from the class object?

Correct Answer is : Create public member functions to access those data members

8. While using encapsulation, which among the following is possible?

Correct Answer is : Data member’s data type can be changed without changing any other code

9. Which feature can be implemented using encapsulation?

Correct Answer is : Abstraction

10. Find which of the following uses encapsulation?

Correct Answer is : class student{int a; public: void disp(){ cout<

11. Encapsulation helps in writing ___________ classes in java

Correct Answer is : Immutable

12. Which among the following should be encapsulated?

Correct Answer is : The data which is prone to change is near future

13. How can Encapsulation be achieved?

Correct Answer is : Using Access Specifiers

14. Which among the following violates the principle of encapsulation almost always?

Correct Answer is : Global variables

15. Which among the following would destroy the encapsulation mechanism if it was allowed in programming?

Correct Answer is : Using access declaration for private members of base class

16. Which among the following can be a concept against encapsulation rules?

Correct Answer is : Using any kind of pointer/array address in passing to another function

17. Consider the following code and select the correct option: class student { int marks; public : int* fun() { return &marks; } }; main() { student s; int *ptr=c.fun(); return 0; }

Correct Answer is : This code violates encapsulation

18. Consider the code and select the wrong choice: class hero { char name[10]; public : void disp() { cout<
Correct Answer is : This maintains encapsulation


19. Encapsulation is the way to add functions in a user defined structure.

Correct Answer is : FALSE

20. Using encapsulation data security is ___________

Correct Answer is : Ensured to some extent

Similar Interview Questions

    Search for latest jobs

    Icon
    Icon