Que- Which among the following is false for class features?
a. Classes may/may not have both data members and member functions
b. Class definition must be ended with a colon
c. Class can have only member functions with no data members
d. Class is similar to union and structures
Ans- Class definition must be ended with a colon
Que- Instance of which type of class can't be created?
a. Anonymous class
b. Nested class
c. Parent class
d. Abstract class
Ans- Abstract class
Que- Which definition best describes an object?
a. Instance of a class
b. Instance of itself
c. Child of a class
d. Overview of a class
Ans- Instance of a class
Que- How many objects can be declared of a specific class in a single program?
a. 32768
b. 127
c. 1
d. As many as you want
Ans- As many as you want
Que- Which among the following is false?
a. Object must be created before using members of a class
b. Memory for an object is allocated only after its constructor is called
c. Objects can't be passed by reference
d. Objects size depends on its class data members
Ans- Objects can't be passed by reference
Que- Which of the following is incorrect?
a. class student{ }s;
b. class student{ }; student s;
c. class student{ }s[];
d. class student{ }; student s[5];
Ans- class student{ }s[];
Que- The object can't be:
a. Passed by reference
b. Passed by value
c. Passed by copy
d. Passed as function
Ans- Passed as function
Que- What is size of the object of following class (64 bit system)?class student { int rollno; char name[20]; static int studentno; };
a. 20
b. 22
c. 24
d. 28
Ans- 24
Que- How members of an object are accessed?
a. Using dot operator/period symbol
b. Using scope resolution operator
c. Using member names directly
d. Using pointer only
Ans- Using dot operator/period symbol
Que- If a local class is defined in a function, which of the following is true for an object of that class?
a. Object is accessible outside the function
b. Object can be declared inside any other function
c. Object can be used to call other class members
d. Object can be used/accessed/declared locally in that function.
Ans- Object can be used/accessed/declared locally in that function.
Que- Which among the following is wrong?
a. class student{ }; student s;
b. abstract class student{ }; student s;
c. abstract class student{ }s[50000000];
d. abstract class student{ }; class toppers: public student{ }; topper t;
Ans- abstract class student{ }; student s;
Que- Object declared in main() function:
a. Can be used by any other function
b. Can be used by main() function of any other program
c. Can't be used by any other function
d. Can be accessed using scope resolution operator
Ans- Can't be used by any other function
Que- When an object is returned___________
a. A temporary object is created to return the value
b. The same object used in function is used to return the value
c. The Object can be returned without creation of temporary object
d. Object are returned implicitly, we can't say how it happens inside program
Ans- A temporary object is created to return the value
Que- Which feature of OOP indicates code reusability?
a. Encapsulation
b. Inheritance
c. Abstraction
d. Polymorphism
Ans- Inheritance
Que- If a function can perform more than 1 type of tasks, where the function name remains same, which feature of OOP is used here?
a. Encapsulation
b. Inheritance
c. Polymorphism
d. Abstraction
Ans- Polymorphism
Que- If different properties and functions of a real world entity is grouped or embedded into a single element, what is it called in OOP language?
a. Inheritance
b. Polymorphism
c. Abstraction
d. Encapsulation
Ans- Encapsulation
Que- Which of the following is not feature of pure OOP?
a. Classes must be used
b. Inheritance
c. Data may/may not be declared using object
d. Functions Overloading
Ans- Data may/may not be declared using object
Que- Which among the following doesn't come under OOP concept?
a. Platform independent
b. Data binding
c. Message passing
d. Data hiding
Ans- Platform independent
Que- 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
Ans- Basically all the features of OOP gets violated
Que- How many basic features of OOP are required for a programming language to be purely OOP?
a. 7
b. 6
c. 5
d. 4
Ans- 7
Que- The feature by which one object can interact with another object is:
a. Data transfer
b. Data Binding
c. Message Passing
d. Message reading
Ans- Message Passing
Que- ___________ underlines the feature of Polymorphism in a class.
a. Nested class
b. Enclosing class
c. Inline function
d. Virtual Function
Ans- Virtual Function
Que- 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
Ans- Operator Overloading
Que- Which among doesn't illustrates polymorphism?
a. Function overloading
b. Function overriding
c. Operator overloading
d. Virtual function
Ans- Function overriding
Que- 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
Ans- The language must follow all the rules of OOP
Que- OOP provides 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
Ans- Always true for any programming language
Que- Which among the following best describes polymorphism?
a. It is the ability for a message/data to be processed in more than one form
b. It is the ability for a message/data to be processed in only 1 form
c. It is the ability for many messages/data to be processed in one way
d. It is the ability for undefined message/data to be processed in at least one way
Ans- It is the ability for a message/data to be processed in more than one form
Que- What do you call the languages that support classes but not polymorphism?
a. Class based language
b. Procedure Oriented language
c. Object-based language
d. If classes are supported, polymorphism will always be supported
Ans- Object-based language
Que- Which among the following is the language which supports classes but not polymorphism?
a. SmallTalk
b. Java
c. C++
d. Ada
Ans- Ada
Que- If same message is passed to objects of several different classes and all of those can respond in a different way, what is this feature called?
a. Inheritance
b. Overloading
c. Polymorphism
d. Overriding
Ans- Polymorphism
Que- Which type of function among the following shows polymorphism?
a. Inline function
b. Virtual function
c. Undefined functions
d. Class member functions
Ans- Virtual function
Que- In case of using abstract class or function overloading, which function is supposed to be called first?
a. Local function
b. Function with highest priority in compiler
c. Global function
d. Function with lowest priority because it might have been halted since long time, because of low priority
Ans- Function with highest priority in compiler
Que- Which among the following can't be used for polymorphism?
a. Static member functions
b. Member functions overloading
c. Predefined operator overloading
d. Constructor overloading
Ans- Static member functions
Que- Which among the following can show polymorphism?
a. Overloading||
b. Overloading +=
c. Overloading <<
d. Overloading &&
Ans- Overloading <<
Que- Which problem may arise if we use abstract class functions for polymorphism?
a. All classes are converted as abstract class
b. Derived class must be of abstract type
c. All the derived classes must implement the undefined functions
d. Derived classes can't redefine the function
Ans- All the derived classes must implement the undefined functions
Que- Which among the following is not true for polymorphism?
a. It is feature of OOP
b. Ease in readability of program
c. Helps in redefining the same functionality
d. Increases overhead of function definition always
Ans- Increases overhead of function definition always
Que- If 2 classes derive one base class and redefine a function of base class, also overload some operators inside class body. Among these two things of function and operator overloading, where is polymorphism used?
a. Function overloading only
b. Operator overloading only
c. Both of these are using polymorphism
d. Either function overloading or operator overloading because polymorphism can be applied only once in a program
Ans- Either function overloading or operator overloading because polymorphism can be applied only once in a program
Que- Which among the following best describes encapsulation?
a. It is a way of combining various data members into a single unit
b. It is a way of combining various member functions into a single unit
c. It is a way of combining various data members and member functions into a single unit which can operate on any data
d. It is a way of combining various data members and member functions that operate on those data members into a single unit
Ans- It is a way of combining various data members and member functions that operate on those data members into a single unit
Que- If data members are private, what can we do to access them from the class object?
a. Create public member functions to access those data members
b. Create private member functions to access those data members
c. Create protected member functions to access those data members
d. Private data members can never be accessed from outside the class
Ans- Create public member functions to access those data members
Que- While using encapsulation, which among the following is possible?
a. Code modification can be additional overhead
b. Data member's data type can be changed without changing any other code
c. Data member's type can't be changed, or whole code have to be changed
d. Member functions can be used to change the data type of data members
Ans- Data member's data type can be changed without changing any other code
Que- Which feature can be implemented using encapsulation?
a. Inheritance
b. Abstraction
c. Polymorphism
d. Overloading
Ans- Abstraction
Que- Encapsulation helps in writing ___________ classes in java
a. Mutable
b. Abstract
c. Wrapper
d. Immutable
Ans- Immutable
Que- Which among the following should be encapsulated?
a. The data which is prone to change is near future
b. The data prone to change in long terms
c. The data which is intended to be changed
d. The data which belongs to some other class
Ans- The data which is prone to change is near future
Que- How can Encapsulation be achieved?
a. Using Access Specifiers
b. Using only private members
c. Using inheritance
d. Using Abstraction
Ans- Using Access Specifiers
Que- Which among the following violates the principle of encapsulation almost always?
a. Local variables
b. Global variables
c. Public variables
d. Array variables
Ans- Global variables
Que- Which among the following would destroy the encapsulation mechanism if it was allowed in programming?
a. Using access declaration for private members of base class
b. Using access declaration for public members of base class
c. Using access declaration for local variable of main() function
d. Using access declaration for global variables
Ans- Using access declaration for private members of base class
Que- Which among the following can be a concept against encapsulation rules?
a. Using function pointers
b. Using char* string pointer to be passed to non-member function
c. Using object array
d. Using any kind of pointer/array address in passing to another function
Ans- Using any kind of pointer/array address in passing to another function
Que- Using encapsulation data security is ___________
a. Not ensured
b. Ensured to some extent
c. Purely ensured
d. Very low
Ans- Ensured to some extent