Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
84 views
Oop MCQ
Uploaded by
kirolos
AI-enhanced title
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save oop_mcq For Later
Download
Save
Save oop_mcq For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
84 views
Oop MCQ
Uploaded by
kirolos
AI-enhanced title
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save oop_mcq For Later
Carousel Previous
Carousel Next
Save
Save oop_mcq For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 50
Search
Fullscreen
OOPs McQs 1. What is the implicit return type of constructor? No return type None 2. When is the abject created with a new keyword? At compile time Depends on the code Hide 23, Identify the incorrect constructor type. Default constructor Parameterized constructor Copy constructor Hide |4. Identify the scope resolution operator. Hide 5, Choose the option below which is not a member of the class. Static function Virtual function Const function Hide 6. Total types of constructors in C++ are?Hide Hide 2 4 What is the number of parameters that 2 default constructor requires? 1 2 3 8, Data members and member functions of a class are private. default. True or False? Hide False Depends on code 9. Under which pillar of COPS do base class and derived class relationships come? Hide Polymer Encapsulation Abstraction +10. Which of the following functions can be inherited from the base class? Hide Constructor Destructor Static 11. Which of the following is not a type of inheritance? Multiple Mubilevel HierarchicalHide 112, What is an object in c++? fis a function of class Itis the data type of class Itis part of the syntax of class. 13, Why is reusability @ desirable feature? Reduces compilation time Lowers maintenance cost Hide 114, identify the operators which cannot be overloaded. {dot operator) Hide 15, Another name of overloading is? Pseude polymorphism ‘Transient polymorphism Virtual polymorphism Hide 16, By default, fields ina structure of @ C program is? Private protected ide 117, On what basis s it determined, when a variable comes into existence in memory? Date typeHide 19, Total access specifiers in OOPS for C++ are? Hide 20. Choose the option below which can show polymorphism. ‘Overloading | ‘Overloading && ‘Overloading += 21. Sel lect the following which shows the correct constructor. class name -class.name class name) 22.70 access data members of class, which of the following is used? Dot operator Arrow operator Dot arrow, or direct call23. Identify the feature, which is used to reduce the use of nested classes. Binding Encapsulation Abstraction Hide 24. Choose the option below whi is used to free the memory allocated for an object in C++. Freeg unallocate() collect Hide 25, Identify the option below which is not a property of the object. Attributes Identity Properties 26. What type of inheritance does single-level inheritance support? Compile-time Mubiple inheritances Language independent 27. In which of the following is memory allocated for the objects? HOD Hide 28, How do encapsulation and abstraction differ? Hiding and binding Hiding and hidingHide 29, Choose the option below which is shown by function overriding Abstraction Encapsulation Inheritance Hide 130. Choose the option below far which instance of the class cannot be created. ‘Anonymous class Parent class Nested class Hide 31, Identify the feature which can be implemented using encapsulation. Encapsulation Polymorphism Inheritance +32, Why is a virtual function mainly used to achieve? Function code polymorphism Interpreter polymorphism ‘Compile-time polymorphism Hide 33, Virtual functions should be defined in? Derived class Both base and derived class None Hide +24, Virtual function should bePrivate protected default Choose whether True or False: The constructor function can be constant. True Depends on implementation Hide Dynamic memory allocation can be done using? calloc) malloc) g Hide Total types of polymorphism in C++ are? * Hide Hide Another name of the generic class is? Final class Abstract class Efficient code 1. Choose the option below which overloads using the friend function,Hide 40, Choose whether True or False: Object cannot be passed as a function. False Depends on implementation None Hide 41. Identify the pure object-oriented programming language among the following, cee Java Python Hide “42, Identify the abstract data type among the following, double int 43, What are the total catch blocks that can be used using a single Try block? Maximum 256 Hide 44, Choose the incorrect option below which is not a type of constructar. Copy constructor Parameterized constructor Default constructor 49, Total instances of an abstract class that can be created?46, Identify the option below which cannot be used with the term “virtual”. destructor class ‘Member function Hide 47. Which type of inheritance is implemented in the following code below? Single inheritance ‘Multilevel inheritance Hybrid inheritance Hide 48, Choose the option below which is used to implement late binding. Friend function Static function Const function 49, What is cout? g Function Hide 50. Choose the option below which describes the overloading of functions. Virtual polymorphism Pseudo polymorphism ‘Transient polymorphism Hide51, Who developed object-oriented programming? Dennis Ritchie Charles Babbage Andrea Ferro: 52. Wt hich of the following is not an oops concept? Inheritance Polymorphism Hide EncapsulationHere are 1000 MCQs on Object Oriented Programming (Chapterwise). 1, Who invented OOP? a) Andrea Ferro b) Adele Goldberg ©) Alan Kay d) Dennis Ritchie fi view Answer Answer: ¢ Explanation: Alan Kay invented OOP, Andrea Ferro was a part of SmallTalk Development. Dennis invented C++ and Adele Goldberg was in team to develop SmaliTalk but Alan actually had got rewarded for OOP. 2. Which is not a feature of OOP in general definitions? a) Efficient Code b) Code reusability c] Modularity ) Duplicate/Redundant data A View Answer Answer: d Explanation: Duplicate/Redundant data is dependent on programmer and hence can't be guaranteed by OOP. Code reusability is done using inheritance. Modularity Is supported by using different code files and classes. Codes are more efficient because of features of OOP, 3. Which was the first purely object oriented programming language developed? a) Kotlin b) SmallTalk lava dy) Ct P View Answer Answer: b Explanation: SmallTalk was the first programming language developed which was purely object oriented. It was developed by Alan Kay. OOP concept came into the picture in 1970's. 4, When OOP concept did first came into picture? a) 1980's b) 1995 1) 1970s a) 1993 P View AnswerAnswer: ¢ Explanation: OOP first came into picture in 1970's by Alan and his team. Later it was used by some programming languages and got implemented successfully, SmaliTalk was first language to use pure OOP and followed all rules strictly. 5. Which feature of OOP indicates code reusability? a) Abstraction b] Polymorphism o) Encapsulation 4) Inheritance (View Answer Answer: d Explanation: Inheritance indicates the code reusability. Encapsulation and abstraction are meant to hide/group data into one element. Polymorphism is to Indicate different tasks performed by a single entity 6, Which header file is required in C++ to use OOP? a) OOP can be used without using any header file b) stdlibh Ciostream.h ) stdio.n View Answer : We need not include any specific header file to use OOP concept in C++, only specific functions used in code need their respective header files to be included or classes should be defined ifr needed. 7. Why Java is Partially OOP language? a) itallows code to be written outside classes b) it supports usual declaration of primitive data types. It does not support pointers 4d) It doesrtt support all types of (* View Answer eritanceExplanation: As Java supports usual declaration of data variables, itis partial implementation of OOP. Because according to rules of OOP, object constructors must be used, even for declaration of variables. 8. Which among the following doesn't come under OOP concept? a) Data hiding b) Message passing ¢) Platform independent 4) Data binding P View Answer Answe' Explanation: Platform independence is not feature of OOP. C++ supports COP but t's not a platform Independent language. Platform independence depends on the programming language 9, Which is the correct syntax of inheritance? a) class base_classname :access derived_classname{ /*define class body*/ }; b) class derived_classname : access base_classname{ /*define class body*/}; ©) class derived_classname : base_classnamef /*define class bodly*/}: d) class base classname : derived_classnamet /*define class body*/ }; A view Answer| Answer: b Explanation: Firstly, keyword class should come, followed by the derived class name. Colon is must followed by access in which base class has to be derived, followed by the base class name. And finally the body of class. Semicolon after the body is also must. 10. Which feature of OOP is indicated by the following code? class student( int marks; ); cles topperspublic student{ int age; topper(int age){ this.egs-eees } 34 1) Encapsulation and Inheritance b) Inheritance and polymorphism ©) Polymorphism d) Inheritance (ee Answer: a Explanation: 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 overloaded11, The feature by which one object can interact with another object is. a) Message reading b) Message Passing ©) Data transfer d) Data Binding View Answer Answer: b Explanation: 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. 12. Which among the following, for a pure OOP language, is true? @) The language should follow at least 1 feature of OOP b) The language must follow only 3 features of OOP ©) The language must follow all the rules of GOP d) The language should follow 3 or more features of COP View Answer Answer: ¢ Explanation: The language must follow all the rules of OOP to be called a purely OOP language. Even if @ single 00? feature is not followed, then it's known to be a partially OOP language. 13, How many types of access specifiers are provided in OOP (C+)? a+ b)3 o2 at View Answer Answer: b Explanation: Only 3 types of access specifiers are available. Namely, private, protected and public. All these three can be used according to the need of security of members, 14, In multilevel inheritance, which is the most significant feature of OOP used? 2) Code efficiency b) Code readability ©) Flexibility d) Code reusability * View Answer Answer: d Explanation: The classes using multilevel inheritance will use the code in all the subsequent subclasses if available. Hence the most significant feature among the options given is code reusability. This Feature is generally intended to use the data values and reuse the redundant functions.15, What is encapsulation in OOP? 4) Itis 2 way of combining various data members and member functions that operate on those data members into single unit b) Its a way of combining various data members and member functions into a single unit which can operate on any data ¢) [tis @ way of combining various data members into a single unit 4d) It is a way of combining various member functions into a single unit P View Answer Answe Explanation: It is a way of combining both data members and member functions, which operate on those data members, Into a single unit. We call ita class in OOP generally. This feature have helped us modify the structures used in C language to be upgraded into class in C++ and other languages. 16. Which of the following is not true about polymorphism? a) Helps in redefining the same functionality b) Increases overhead of function definition always ) [tis feature of OOP d) Ease in readability of program P View Ansiver Answer: b Explanation: It never increases function definition overhead, one way or another if you don't use polymorphism, you will use the definition in some other way, so it actually helps to write efficient codes. 17. Which constructor will be called from the object created in the below C++ code? class & int ds AQ ino; coutaitjalts’5 ? ACint 200) £ ions coutantsaitsts b A obits a) Parameterized constructor b) Default constructor ) Run time error d) Compile time errorView Answer Answer: d Explanation: When a default constructor is defined and another constructor with 1 default value argument is defined, creating object without parameter will create ambiguity for the compiler. The compiler wor't be able to decide which constructor should be called, hence compile time error. 18, What is an abstraction in object-oriented programming? a) Hiding the implementation and showing only the features b) Hiding the important data ©) Hiding the implementation d) Showing the important data View Answer Answer: a Explanation: It includes hiding the implementation part and showing only the required data and features to the user. Itis done to hide the implementation complexity and detalls from the user. And to provide a good interface in programming. 19. Which among the following can show polymorphism? a) Overloading && ) Overloading << ¢) Overloading || ) Overloading View Answer Answer: b- Explanation: Only insertion operator can be overloaded among all the given options. And the polymorphism can be illustrated here only if any of these is applicable of being overloaded, Overloading is type of polymorphism. 20. In which access should a constructor be defined, so that object of the class can be created in any function? 1) Any access specifier will work b) Private ©) Public ) Protected A View Answer Answer: ¢ Explanation: Constructor function should be available to all the parts of program where the abject is to be created, Hence itis advised to define it in public access, so that any other function is able to create objects, 21. Which among the following is correct for the class defined below? ctass stucent cEnt marks public: student( student (nt x) ‘ marks b ain) t student s1(100); stucent =2()) student s3=100; return 05 » 4) Program nill give compile time error b) Object s3, syntax error ¢) Only object s1 and s2 will be created ) Program runs and all objects are created A View Answer Answer: Explanation: It is a special case of constructor with only 1 argument. While calling a constructor with one argument, you are actually implicitly creating a conversion from the argument type to the type of class. Hence you can directly specify the value of that one argument with assignment operator, 22, The copy constructors can be used to a) Copy an object so that it can be passed to another primitive type variable b) Copy an object for type casting ©) Copy an object so that it can be passed to a function ) Copy an object so that it can be passed to a class f View Ansiver Answer: ¢ Explanation: When an object is passed to a function, actually its copy is made in the function. To copy the values, copy constructor is used. Hence the object being passed and object being used in function are different. 23, Which constructor will be called from the object obj2 in the following C=* program? class & t int i AQ ines ? Aint >) £dewey r Aint y, int x) € ineys B a epji(ie); 1 €b}2(10, 20); a}; a) Alinty, int x) g.atinty) a) agint) f View Answer Answer: Explanation: The two argument constructor will be called 2s we are passing 2 arguments to the object while creation, The arguments will be passed together and hence compiler resolves that two argument constructor have to be called. 24, Which among the following represents correct constructor? a) -classname() b) classname() ¢} ()classname d) ~classnamet) P View Answer Answel Explanation: The constructors must contain only the class name, The class name is followed by the blank parenthesis or we can have parameters if some values are to be passed. 25, What happens when an object is passed by reference? 4) Destructor is called at end of function ) Destructor is called when called explicitly 1) Destructor is not called d) Destructor is called when function is out of scope (ee Answer: ¢ Explanation: The destructor is never celled in this situation. The concept is that when en object is passed by reference to the function, the constructor is not called, but only the main object will be used. Hence no destructor will be called at end of function. 26. Which access specifier Is usually used for data members of a class?a) Protected b) Private ) Public ) Default f View Answer Answer: b Explanation: All the data members should be made private to ensure the highest security of data. In special cases we can use public or protected access, but it is advised to keep the data members private always. 27, Howto access data members of a class? a) Dot, arrow or direct call b) Dot operator <) Arrow operator 4d) Dot or arrow as required P View Answer Answer: d Explanation: The data members can never be called directly. Dot operator is used to access the members with help of object of class. Arrow is usually used if pointers are used. 28, Which feature of OOP reduces the use of nested classes? a) Inheritance b) Binding Abstraction «) Encapsulation f View Answer Answer: a Explanation: Using inheritance we can have the security of the class being Inherited. The subclass can access the members of parent class. And have more feature than a nested cless being used. 29. Which keyword among the following can be used to declare an array of objects in java? a) allocate b) arr new d) create P View Answer Answer Explanation: The keyword new can be used to declare an array of objects in java. The syntax must be specified with an object pointer which is assigned with a memory space containing the required number of object space. Even initialization can be done directly.30. Which operator can be used to free the memory allocated for an object in C+#2 a) Unallocate b) Free() ¢) Collect d) delete P View Answer Explanation: The delete operator in C++ can be used to free the memory and resources held by an object. The function can be called explicitly whenever required. In C++ memory management must be done by the programmer. There is no automatic memory management in C++. 31, Which of the following is not a property of an object? a) Properties b) Names J identity d) Attributes f View Answer Answer: Explanation: The names are not property of an object. The identity can be in any form like address or name of object but name can't be termed as only identity of en object. The objects contain attributes that define what type of data an object can store. 32. Which type of members can't be accessed in derived classes of a base class? a) All can be accessed b) Protected <) Private d) Public P View Answer Answer: ¢ Explanation: The private members can be accessed only inside the base class. If the class is derived by other classes, Those members will not be accessible. This concept of OOP is made to make the members more secure. 33, Which among the following best describes the Inheritance? 4a) Using the data and functions into derived segment ') Using already defined functions in a programming language ) Using the code already written once ) Copying the code already written P View Ansiver Answer:@Explanation: It can only be indicated by using the data and functions that we use in derived class, being provided by parent class. Copying code is nowhere similar to this concept, also using the code already written is same as copying. Using already defined functions is not inheritance as we are nat adding any of our own features. 34, Single level inheritance supports inheritance. a) Language independency b) Multiple inheritance ) Compile time d) Runtime A View Answer Explanation: The runtime inheritance is done when object of a class is created to call a method. At runtime the function is searched ifit is in class of object. if not, it will search in its parent classes and hierarchy for that method. 35, How to overcome diamond problem? a) Using seperate derived class b) Using virtual keyword with same name function ¢) Cant be done d) Using alias name (eens Answer: b- Explanation: To overcome the ambiguity and conflict we cen use keyword virtual. This will help us to differentiate the functions with same name that came to last derived class in diamond problem. 36. Which keyword is used to declare virtual functions? a) vit ) virtually )virtual 4) anonymous P View Answer Answer: Explanation: The virtual keyword is used to declare virtual functions. Anonymous keyword is used with classes and have different meaning. The virtual functions are used to call the intended function of the derived class. 37. What happens if non static members are used in static member function? 1) Executes fine b) Compile time error ) Executes if that member function is not used d) Runtime errorfunctions uses them. But the space is not reserved if object is nat declared. Hence only if static members are not used, it leads to compile time error. 38, What is friend member functions in C+#? a) Non-member functions which have access to all the members (including private) of a class b) Member function which doesn't have access to private members ¢) Member function which can modify any data of a class ) Member function which can access all the members of a class f View Answer Answer: 2 Explanation: A non-member function of a class which can access even the private data of a class is a friend function. It is an exception on access to private members outside the class. It is sometimes considered as 4 member functions since it has all the access that a member function in general have. 39, Where is the memory allocated for the objects? a) Cache b)ROM ) HDD a) RAM P View Answer Answel Explanation: The memory for the objects or any other data is allocated in RAM initially. This is while we run a program all the memory allocation takes place in some RAM segments. Arrays in heap and local members in stack etc. 40. Which of the following best describes member function overriding? 1a) Member functions having the same name in derived class only 'b) Member functions having the same name and different signature inside main function ) Member functions having the same name in base and derived classes cd) Member functions having the same name in base class only P View Ansiver Answer: ¢ Explanation: The member function which is defined in base class and again in the derived class, is overridden by the definition given in the derived class. This is because the preference is given more to the local members. When derived class object calls that function, definition from the derived class is used.41. Encapsulation and abstraction differ as 2) Hiding and hiding respectively b) Binding and Hiding respectively ©) Hiding and Binding respectively d) Can be used any way * View Answer Answer: b Explanation: Abstraction is hiding the complex code. For example, we directly use cout object in C++ but we dont know how is it actually implemented, Encapsulation is data binding, as in, we try to combine a similar type of data and functions together. 42. Which feature of OOP is exhibited by the function overri @) Polymorphism b) Encapsulation Abstraction d) Inheritance ® View Answer Answer: a Explanation: The polymorphism feature is exhibited by function overriding. Polymorphism is the feature which basically defines that same named functions can have more than one functionalities. 43. How to access the private member function of a class? a) Using class address b) Using object of dass ) Using object pointer ¢) Using address of member function View Answer Answer: d Explanation: Even the private member functions cen be called cutside the class. function is known, We can use the address to call the function outside the class. possible if address of the 44, Which keyword should be used to declare static variables? a) const, b) common ©) static d)stat View Answer Answer: ¢ Explanation: The keyword used to declare static variables is static. This is must be used while declaring the static variables. The compiler can make variables static if and only if they are mentioned with static keyword.45, Which is correct syntax for declaring pointer to object? a) FclassName objectName; b) className* objectName; ¢) className objectName(); d) className objectName; P View Answer Answer: b Explanation: The syntax must contain * symbol after the className as the type of object. This declares an object pointer. This can store address of any object of the specified class. 46, Which class/set of clesses cen illustrate polymorphism in the following Cr+ code? abstract class student t public : int marks; ccale_grade()s » less topper ipublic student ‘ public + cole_grade() { return 105 B class average:suoiic student £ public t alc grade) return 20; B close feiled( int marks Js a) Only class student and topper together can show polymorphism b) Only class student can show polymarphism ©) Class failed should also inherit class student for this code to work for polymorphism 4d) All class student, topper and average together can show polymorphism f View Ansiver Answer: d Explanation: Since Student class is abstract class and class topper and average are inheriting student, class topper and average must define the function named calc_gradeQ; in abstract class. Since both the definition are different in those classes, calc_grade() will work in different way for same input from different objects. Hence it shows polymorphism. 47. data members are private, what can we do to access them from the class object?4) Private data members can never be accessed from outside the class b) Create public member functions to access those data members ¢) Create private member functions to access those data members d) Create protected member functions to access those data members P View Answer Answer: b- Explanation: We can define public member functions to access thase private data members and get their value for use or alteration. They can't be accessed directly but is possible to be access using member functions. This is done to ensure that the private data doesn't get modified accidentally. 48, Which among the following is not a necessary condition for constructors? a) Its name must be same as that of class b) It must not have any return type ¢) It must contain a definition body 4d) It can contains arguments A View Answer Answe Explanation: Constructors are predefined implicitly, even if the programmer doesnt define any of them. Even if the programmer declares a constructor, it's not necessary that it must contain some definition. 49, Object being passed to a copy constructor a) Must not be mentioned in parameter list b) Must be passed with integer type ) Must be passed by value d) Must be passed by reference fi view Answer Answer: d Explanation: This is mandatory to pass the object by reference. Otherwise, the object will try to create another object to copy its values, in turn a constructor willbe called, and this will keep on calling itself. This will cause the compiler to give out of memory error. 50. if in multiple inheritance, class C inherits class 8, and Class 8 inherits class A. In which sequence are their destructors called if an object of class C was declared? a) -A() then -B0 then ~CO) b) ~C() then ~AQ then ~B) ¢) ~C{) then ~&() then ~A0) d) ~B() then ~CO) then ~A() f View Answer Answer: Explanation: The destructors are always called in the reverse order of how the constructors were called. Hereclass A constructor would have been created first if Class C object is declared. Hence class A destructor is called atlast. 51. Instance of which type of class cant be created? a) Parent class ) Abstract class ) Anonymous class d) Nested class P View Answer Answer: b Explanation: Instance of abstract class can't be created as it will not have any constructor of its own, hence while creating an instance of class, it cant initialize the object members. Actually the class inheriting the abstract class can have its instance because it will have implementation of all members. 52, underlines the feature of Polymorphism in a class. a) Virtual Function by Inline function, ©) Enclosing class d) Nested class P View Answer Answer: Explanation: 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. 53, Which feature in OOP is used to allocate additional functions to a predefined operator a) Function Overloading ) Function Gverriding ¢) Operator Overloading d) Operator Overriding any language? (ees Answer: ¢ Explanation: The feature is operator overloading. There is not ¢ feature named operator overriding specifically. Function overloading and overriding doesn't give addition function to any operator. 54, Which feature can be implemented using encapsulation? a) Polymorphism b) Overloading ¢) Inheritance 4) Abstractionjew Answer Answer: d Explanation: Data abstraction can be achieved by using encapsulation. We can hide the operation and structure of actual program from the user and can show only required information by the user.OOPS MCQ 1) Which of the following language was developed as the first purely object programming language? a. SmallTalk b. C++ c. Kotlin d. Java D Hide answer [F Workspace Answer: a. SmallTalk Explanatio language. This language wes designed by Alan Kay in the early 1970s. This programming language was invented as the first pure OOPS (object-oriented) 2) Who developed object-oriented programming? a. Adele Goldberg b. Dennis Ritchie c. Alan Kay d. Andrea Ferro ®@D Hide Answer [BP Workspace Answer: c. Alan Kay Explanation: In the year 1970, Alan Kay gave Object-Oriented programming, He coined the concept of OOPS at a grad school in the year 1966 or 1967. Alan kay, Adele Goldberg, Dan Ingalls and others developed the first Smalltalk programming language, which follows the OOPS concept. 3) Which of the following is not an OOPS concept? a. Encapsulationb. Polymorphism c. Exception d. Abstraction ®D Hide Answer (@ Workspace Answer: c. Exception Explanation: None. 4) Which feature of OOPS described the reusability of code? a. Abstraction b. Encapsulation c. Polymorphism d. Inheritance ®D Hide Answer (® Workspace Answer: d. Inheritance Explanation: Inheritance is the feature of OOPS, which allows the users of OOPS to reuse the code which is already written. This QOPS feature inherits the features of another class in the programs. This mechanism actually inherits the fields and methads of the superclass. 5) Which of the following language supports polymorphism but not the classes? a. C++ programming language b. Java programming language c. Ada programming language d. C# programming languageD Hide Answer (BF Workspace Answer: c. Ada programming language Explanation: it is @ programming language that disapproves of the concept of polymorphism but supports the concept of classes. It is an object-based language. So, it does not follow the Object- oriented programming concepts. 6) Which among the following feature is not in the general definition of OOPS? a. Modularity b. Efficient Code c. Code reusability d. Duplicate or Redundant Data ® Hide Ancwor [B Workspace Answer: d. Duplicate or Redundant Data Explanation: Duplicacy or Redundancy of data is a feature which totally dependent on the programmers. So, it cannot be created by the OOPS. 7) Which feature of OOPS derives the class from another class? a. Inheritance b. Data hiding c. Encapsulation 4d. Polymorphism D Hide Answer [JP Workepace Answer: a. Inheritance Explanation: inheritance is an important OOPS feature which derives the class from the base class or superclass. This OOPS feature inherits the features of another class in the programs. Thismechanism actually inherits the fields and methods of the superclass. 8) Define the progremming language, which does not support all four types of inheritance? a. Smalltalk b. Kotlin c. Java d. C++ D tide answer (FF Workspace Answer: c. Java Explanati pproves of the concept of ‘multiple inheritance’. So, it does not agree with all types of inheritance. But, we can implement ‘multiple Java is a programming language that inheritance’ in Java language using the interface concept. 9) Asingle program of OPS contains classes? a. Only 1 b. Only 999 c. Only 100 d. Any number D Hide Anower ——_( Workepace Answer: d. Any number We can define any number of classes with different names in a single program of 10) Which operator from the following can be used to illustrate the feature of polymorphism? 2. Overloading <<b. Overloading && c. Overloading || d. Overloading += ®D Hide Answer (@ Workspace Answer: a. Overloading << Explanation: << is an insertion operator which is used for overloading (polymorphism). 11) Which two features of object-oriented programming are the same? a. Abstraction and Polymorphism features are the same b. Inheritance and Encapsulation features are the same . Encapsulation and Polymorphism features are the seme d. Encapsulation and Abstraction D Hide Answer [@ Workspace Answer: d. Encapsulation and Abstraction Explanation: Encapsulation and Abstraction are the same OOPS concepts. Encapsulation hides the features of the object and binds all the properties inside a single class. And abstraction is a feature that shows the required data to the user. 12) Which header file is required by the C++ programming language to use the OOPS concept? a. stdio.h b. iostream.h c. stdlib.h d. We can easily use the OPS concepts in c++ programs without using any header file@D Hide Answer [PB Workspace Answer: d. We can easily use the OOPS concepts in c++ programs without using any header file. Explanation: There is no need to use any particular header file for using the OOPS concept in the C++ programs. The C++ functions and variables have their respective header files, which should be defined in the program. 13) Which of the following definition is incorrect for polymorphism? a. Polymorphism helps in redefining the same functionality b, Polymorphism concept is the feature of object-oriented programming (OOP) . Italways increases the overhead of function definition d. Ease in the readal ity of the program D tide answer (BF Workspace Answer: c. It always increases the overhead of function definition Explanation: This concept of OOPS never increases the overhead of function definition. 14) Which among the following cannot be used for the concept of polymorphism? a, Static member function b. Constructor Overloading Member funk ion overloading d. Global member function @ Hide anewor [B Workspace Answer: a. Static member function Explanation: These functions are not an object property. That's why they cannot be acceptable for overriding or overloading15) Which function best describe the concept of polymorphism in programming languages? a. Class member function b. Virtual function c. Inline function d. Undefined function D Hide Answer Workspace Answer: b. Virtual function Explan ‘virtual’. These functions let the OOPS programs decide at runtime which function is to be called by In: Only those functions are used to achieve the polymorphism, which are declared as the pointer. 16) Which member function is assumed to call first when there is a case of using function overloading or abstract class? a. Global function b. Local function c. Function with lowest priority d. Function with the highest priority @ Hide Answer [5 Workspace Answer: d, Function with the highest pricrity Explanation: The member function with the highest priority is called first when there is function overloading, or abstract class is used 17) Isit true to use polymorphism in the C programming language? a. Trueb. False D Hide Answer (PF Workspace Answer: a. True Explanati can use structures and then declare pointers in C programming language, which in tum points to some function. 2: Yes, we can use the concept of polymorphism in the C programming language. Users Here, he/she can easily simulate the functions which are not exactly member function. Hence, users can manipulate the concept of polymorphism in the C language. 18) Which of the following language uses the classes but not the polymorphism concept? a. Procedure Oriented language b, Object-based language c. Class-based language . If classes are used, then the polymorphism concept will always be used in the programming languages. @ Hide answer [GP Workspace ‘Answer: b. Object-based language Explanation: Object-based languages are those languages which support the definition of classes but not the polymorphism. Inheritance is also another feature which is not supported by these languages. 19) Which of the following OOP concept is not true for the C+ + programming language? a. A class must have member functions b. C++ Program can be easily written without the use of classes c. At least one instance should be declared within the C++ program d. C++ Program must contain at least one classD Hide Answer [@ Workspace Answer: d. C++ Program must contain at least one class Explanation: Use of class in the C++ language is not mandatory. Programs can be easily written without the use of classes. C++ programs classes may or may not contain the member function. That's why it is not a necessary situation in the C++ language. 20) What is the extra feature in classes which was not in the structures? a. Member functions b. Data members c. Public access specifier d. Static Data allowed ®@D Hide Answer (BP Workspace Answer: a. Member functions Member function is an extra feature which is allowed in class but not in the concept of Explanation: structures. 21) How many types of polymorphism in the C++ programming language? a. Three types of polymorphism b. Two types of polymorphism <. Five types of polymorphism d. Four types of polymorphism D Hide answer (F Workspace Answer: b. Two types of polymorphismExplani Polymorphism 2. Compile-time Polymorphism : C++ programming language has two types of polymorphism: 1. Runtime Runtime Polymorphism: It is meet by the function overriding. This polymorphism is also known as late or dynamic binding Compile-time Polymorphism: it is meet by the operator and function overloading, This polymorphism is also known as early or static binding. 22) Which of the following feature is also known as run-time binding or late binding? a. Dynamic typing b. Dynamic loading cc. Dynamic binding . Data hiding ee ®D Hide Answer [@ Workspace Answer: c. Dynamic binding Explanation: Dynamic binding or runtime binding or late binding is that type of binding which happens at the execution time of the program or code. Function or method overriding is the perfect example of this type of binding. Virtual functions are used to achieve the concept of function overriding. 23) Which among the following is not a member of the class? a. Virtual function b. const fun n . Static function d. Friend functionD Hide Answer Workspace Answer: d. Friend function Explanation: The public member functions of a class can easily access the private data members of the same class. This is achieved by the “friend”, which is a non-member function to the class. Its private data can be accessed. That's why the friend function is not a member of the class. 24) Which of the following class is known as the generic class? a. Final class b. Template class c. Abstract class d. Efficient code @ Hida Anewor —_ Workepaco Answer: b. Template class Explanation: Template classes are those classes which can be used for any value of data type. So, these are known as a generic class. Template classes help in making the genetic classes and generate the objects of classes based on the parameters. This type of class also saves system memory. 25) Which operator overloads using the friend function?@ Hide Answor [B Workspace Answer: a. * ->, (), =) cannot be overloaded using the friend function because if Explanation: The operators ( ion error. That's why * (asterisk) is a they are overloaded, then the code will show the compi symbol that can be overloaded using the friend function 26) Which of the following OOP concept binds the code and data together and keeps them secure from the outside world? 2. Polymorphism b. Inheritance c. Abstraction <. Encapsulation D tide answer (B wiorispace Answer: d, Encapsulation Explanation: Encapsulation is an important concept of Object-oriented programming, This concept manipulate the data. binds the data and methods in @ single unit. It binds the methods whit 27] Which member of the superclass is never accessible to the subclass? @. Public member b, Protected member . Private member 4d, All of the mentioned @ Hide Answer [B Workspace Answer: c. Private member Explanation: Private is a member of a class which never be accessible to the derived class.28) What is the size of a class? a. Sum of the size of all inherited variables along with the variables of the same class b. The size of the class is the largest size of the variable of the same class c. Classes in the programming languages do not have any size d. Sum of the size of all the variables within a class. ®D Hide Answer (@ Workspace Answer: c. Classes in the programming languages do not have any size Explanation: The object size defines the size of the class. That's why classes do not have any size. 23) Which class cannot create its instance? a. Parent class b. Nested class c. Anonymous class d. Abstract class ®D Hide Answer (® Workspace Answer: d. Abstract class Explanation: The instance of the abstract class can't be created because it will not have any constructor of its own. Hence while creating an instance of a class, it can't initialize the object members. 30) Encapsulation adds the function in a user-defined structure, a. True b. FalseD Hide Answer BP Workspace Answer: b. False Explanation: The encapsulation concept does not add the function in a user-defined structure because if the member functions are involved, then the user cannot call the structures defined by it. 31) Which of the following variable violates the definition of encapsulation? a. Array variables b. Local variables cc. Global variables d. Public variables ®@D Hide Answer (BP Workspace Answer: c. Global variables Explanation: Global variable is a variable which violates the definition of encapsulation. The definition of encapsulation defines that the data or variable should be accessed by the specified set of elements. But, the global variable is accessible everywhere in the code. This type of variable does not hide the internal performance of the code. That's global variable violates the encapsulation concept, 22) How can the concept of encapsulation be achieved in the program? a. By using the Access specifiers b. By using the concept of Abstraction <. By using only private members d. By using the concept of Inheritance D Hide answer (F WorkspaceAnswer: a. By using the Access specifiers Explanation: Users can achieve the concept of encapsulation by implementing the access specifiers in the code. It is not compulsory that the user use only private members. 33) The concept of encapsulation helps in writing which type of classes in the Java programming language? a. Abstract classes b. Wrapper classes c. Mutable classes d. Immutable classes D Hide answer (F Workspace Answer: d. Immutable classes Explanation The concept of encapsulation helps in writing immutable classes in the Java programming language because these classes are used for caching purposes. 34) Encapsulation is 2. technique of combining more than one member functions into a single unit. b. mechanism of combi 1g more than one data member into a single unit. c. mechanism of combining more than one data members and member functions that implement on those data members into a single u 4G. technique of combining more than one data members and member functions into a single unit which can manipulate any data.
You might also like
The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life
From Everand
The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life
Mark Manson
4/5 (6387)
Principles: Life and Work
From Everand
Principles: Life and Work
Ray Dalio
4/5 (634)
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
From Everand
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
Brené Brown
4/5 (1160)
Never Split the Difference: Negotiating As If Your Life Depended On It
From Everand
Never Split the Difference: Negotiating As If Your Life Depended On It
Chris Voss
4.5/5 (983)
The Glass Castle: A Memoir
From Everand
The Glass Castle: A Memoir
Jeannette Walls
4/5 (8302)
Grit: The Power of Passion and Perseverance
From Everand
Grit: The Power of Passion and Perseverance
Angela Duckworth
4/5 (633)
Sing, Unburied, Sing: A Novel
From Everand
Sing, Unburied, Sing: A Novel
Jesmyn Ward
4/5 (1254)
The Perks of Being a Wallflower
From Everand
The Perks of Being a Wallflower
Stephen Chbosky
4/5 (10337)
Shoe Dog: A Memoir by the Creator of Nike
From Everand
Shoe Dog: A Memoir by the Creator of Nike
Phil Knight
4.5/5 (933)
Her Body and Other Parties: Stories
From Everand
Her Body and Other Parties: Stories
Carmen Maria Machado
4/5 (887)
The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
From Everand
The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
Ben Horowitz
4.5/5 (361)
Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
From Everand
Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
Margot Lee Shetterly
4/5 (1007)
Steve Jobs
From Everand
Steve Jobs
Walter Isaacson
4/5 (3237)
Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
From Everand
Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
Ashlee Vance
4.5/5 (581)
The Emperor of All Maladies: A Biography of Cancer
From Everand
The Emperor of All Maladies: A Biography of Cancer
Siddhartha Mukherjee
4.5/5 (297)
A Man Called Ove: A Novel
From Everand
A Man Called Ove: A Novel
Fredrik Backman
4.5/5 (5058)
Angela's Ashes: A Memoir
From Everand
Angela's Ashes: A Memoir
Frank McCourt
4.5/5 (943)
The Art of Racing in the Rain: A Novel
From Everand
The Art of Racing in the Rain: A Novel
Garth Stein
4/5 (4346)
The Little Book of Hygge: Danish Secrets to Happy Living
From Everand
The Little Book of Hygge: Danish Secrets to Happy Living
Meik Wiking
3.5/5 (458)
The Yellow House: A Memoir (2019 National Book Award Winner)
From Everand
The Yellow House: A Memoir (2019 National Book Award Winner)
Sarah M. Broom
4/5 (100)
Brooklyn: A Novel
From Everand
Brooklyn: A Novel
Colm Toibin
3.5/5 (2091)
Yes Please
From Everand
Yes Please
Amy Poehler
4/5 (1993)
Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
From Everand
Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
Gilbert King
4.5/5 (278)
The World Is Flat 3.0: A Brief History of the Twenty-first Century
From Everand
The World Is Flat 3.0: A Brief History of the Twenty-first Century
Thomas L. Friedman
3.5/5 (2283)
Bad Feminist: Essays
From Everand
Bad Feminist: Essays
Roxane Gay
4/5 (1077)
The Woman in Cabin 10
From Everand
The Woman in Cabin 10
Ruth Ware
3.5/5 (2780)
A Tree Grows in Brooklyn
From Everand
A Tree Grows in Brooklyn
Betty Smith
4.5/5 (2032)
The Outsider: A Novel
From Everand
The Outsider: A Novel
Stephen King
4/5 (2838)
The Sympathizer: A Novel (Pulitzer Prize for Fiction)
From Everand
The Sympathizer: A Novel (Pulitzer Prize for Fiction)
Viet Thanh Nguyen
4.5/5 (141)
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
From Everand
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
Dave Eggers
3.5/5 (692)
Team of Rivals: The Political Genius of Abraham Lincoln
From Everand
Team of Rivals: The Political Genius of Abraham Lincoln
Doris Kearns Goodwin
4.5/5 (1912)
Wolf Hall: A Novel
From Everand
Wolf Hall: A Novel
Hilary Mantel
4/5 (4086)
On Fire: The (Burning) Case for a Green New Deal
From Everand
On Fire: The (Burning) Case for a Green New Deal
Naomi Klein
4/5 (76)
Fear: Trump in the White House
From Everand
Fear: Trump in the White House
Bob Woodward
3.5/5 (830)
Manhattan Beach: A Novel
From Everand
Manhattan Beach: A Novel
Jennifer Egan
3.5/5 (906)
Rise of ISIS: A Threat We Can't Ignore
From Everand
Rise of ISIS: A Threat We Can't Ignore
Jay Sekulow
3.5/5 (143)
John Adams
From Everand
John Adams
David McCullough
4.5/5 (2544)
The Light Between Oceans: A Novel
From Everand
The Light Between Oceans: A Novel
M L Stedman
4.5/5 (813)
The Unwinding: An Inner History of the New America
From Everand
The Unwinding: An Inner History of the New America
George Packer
4/5 (45)
Little Women
From Everand
Little Women
Louisa May Alcott
4.5/5 (2369)
The Constant Gardener: A Novel
From Everand
The Constant Gardener: A Novel
John le Carré
4/5 (277)