Test Series - oops

Test Number 6/78

Q: Which feature of OOP is indicated by the following code?

class student{  int marks;  };
class topper:public student{  int age;  topper(int age){ this.age=age; } };
A. Inheritance
B. Polymorphism
C. Inheritance and polymorphism
D. Encapsulation and Inheritance
Solution: Encapsulation is indicated by use of classes. Inheritance is shown by inheriting the student class into topper class. Polymorphism is not shown here because we have defined the constructor in the topper class but that doesn’t mean that default constructor is overloaded.
Q: Which feature may be violated if we don’t use classes in a program?
A. Inheritance can’t be implemented
B. Object must be used is violated
C. Encapsulation only is violated
D. Basically all the features of OOP gets violated
Solution: All the features are violated because Inheritance and Encapsulation won’t be implemented. Polymorphism and Abstraction are still possible in some cases, but the main features like data binding, object use and etc won’t be used hence the use of class is must for OOP concept.
Q: How many basic features of OOP are required for a programming language to be purely OOP?
A. 7
B. 6
C. 5
D. 4
Solution: There are 7 basic features that define whether a programing language is pure OOP or not. The 4 basic features are inheritance, polymorphism, encapsulation and abstraction. Further, one is, object use is must, secondly, message passing and lastly, Dynamic binding.
Q: The feature by which one object can interact with another object is _____________
A. Data transfer
B. Data Binding
C. Message Passing
D. Message reading
Solution: The interaction between two object is called the message passing feature. Data transfer is not a feature of OOP. Also, message reading is not a feature of OOP.
Q:  ___________ underlines the feature of Polymorphism in a class.
A. Nested class
B. Enclosing class
C. Inline function
D. Virtual Function
Solution: Virtual Functions can be defined in any class using the keyword virtual. All the classes which inherit the class containing the virtual function, define the virtual function as required. Redefining the function on all the derived classes according to class and use represents polymorphism.
Q: Which feature in OOP is used to allocate additional function to a predefined operator in any language?
A. Operator Overloading
B. Function Overloading
C. Operator Overriding
D. Function Overriding
Solution: The feature is operator overloading. There is not a feature named operator overriding specifically. Function overloading and overriding doesn’t give addition function to any operator.
Q: Which among doesn’t illustrates polymorphism?
A. Function overloading
B. Function overriding
C. Operator overloading
D. Virtual function
Solution: Function overriding doesn’t illustrate polymorphism because the functions are actually different and theirs scopes are different. Function and operator overloading illustrate proper polymorphism. Virtual functions show polymorphism because all the classes which inherit virtual function, define the same function in different ways.
Q: Exception handling is a feature of OOP.
A. True
B. False
C. 1
D. 0
Solution: Exception handling is a feature of OOP as it includes classes concept in most of the cases. Also it may come handy while using inheritance.
Q: Which among the following, for a pure OOP language, is true?
A. The language should follow 3 or more features of OOP
B. The language should follow at least 1 feature of OOP
C. The language must follow only 3 features of OOP
D. The language must follow all the rules of OOP
Solution: The language must follow all the rules of OOP to be called a purely OOP language. Even if a single OOP feature is not followed, then it’s known to be a partially OOP language.
Q: Does OOP provide better security than POP?
A. Always true for any programming language
B. May not be true with respect to all programming languages
C. It depends on type of program
D. It’s vice-versa is true
Solution: It is always true as we have the facility of private and protected access specifiers. Also, only the public and global data are available globally or else the program should have proper permission to access the private data.

You Have Score    /10