Object Oriented Programming MCQ (Multiple Choice Questions) - SchoolingAxis

Object Oriented Programming MCQ (Multiple Choice Questions)

 Que- Does use of object reference in assignment or passing means copy of the object is being used? 

a. No, because the copy would create a new temporary variable 

b. No, because the copy would not help to make changes to main object 

c. Yes, because the reference directly means using address 

d. Yes, because the reference directly means the constructors are involved 


Ans- Yes, because the reference directly means using address  


Que- Is there any explicit use of pointers in java that would be applicable to objects? 

a. Yes, we use reference for this purpose 

b. Yes, we use java arrays for this purpose 

c. No, implicit pointing is possible 

d. No, direct class names should be used 


Ans- No, implicit pointing is possible  


Que- Can a super class object give reference to a subclass method? 

a. No, it is not possible 

b. Maybe, it is possible 

c. No, it's not possible 

d. No, It's not possible in few cases only 


Ans- No, it's not possible  


Que- If a reference variable is declared final then, _________________ 

a. It can never be reassigned to refer to a different object. 

b. It can be assigned to refer to any object anytime 

c. It can never be assigned with any object 

d. It can be assigned with 2 or more objects simultaneously 


Ans- It can never be reassigned to refer to a different object.  


Que- Which of the members are referred by this pointer usually (Java)? 

a. Members of class where this is used 

b. Member of the parent class where this is used 

c. Members that are passed as argument to the object 

d. Pointers are not applicable in java 


Ans- Members of class where this is used  


Que- How to refer to method of nested class? 

a. enclosingClassObject.innerClassObject.method(); 

b. innerClassObject.method(); 

c. method(); 

d. depends on where the method is being called 


Ans- depends on where the method is being called  


Que- How many objects can be referenced from same variables? 

a. One at a time 

b. Many at a time 

c. Many using array name 

d. 7 at max at same time 


Ans- One at a time  


Que- Which among the following is true? 

a. Object referencing refers to methods address 

b. Object referencing refers to variable of object 

c. Object referencing points to same address, if assigned by variables 

d. Object referencing is used to point methods 


Ans- Object referencing points to same address, if assigned by variables  


Que- Invoking a method on a particular object is ____________ sending a message to that object. 

a. Different from 

b. Same as 

c. Somewhat similar 

d. Part of 


Ans- Same as  


Que- Can reference to an object be returned from a method? 

a. Yes, always possible 

b. Yes, but not always 

c. No, never possible 

d. No, Not possible because referred element would be destroyed 


Ans- Yes, but not always  


Que- What does memory allocation for objects mean? 

a. Actual creation and memory allocation for object members 

b. Creation of member functions 

c. Creation of data members for a class 

d. Actual creation and data declaration for object members 


Ans- Actual creation and memory allocation for object members  


Que- Where is the memory allocated for the objects? 

a. HDD 

b. Cache 

c. RAM 

d. ROM 


Ans- RAM  


Que- When is the memory allocated for an object? 

a. At declaration of object 

b. At compile time 

c. When object constructor is called 

d. When object is initialized to another object 


Ans- When object constructor is called  


Que- Using new is type safe as _______________________ 

a. It require to be specified with type of data 

b. It doesn't require to be specified with type of data 

c. It requires the name of data 

d. It allocated memory for the data 


Ans- It doesn't require to be specified with type of data  


Que- Which of the following function can be used for dynamic memory allocation of objects? 

a. malloc() 

b. calloc() 

c. create() 

d. malloc() and calloc() 


Ans- malloc() and calloc()  


Que- How much memory will be allocated for an object of class given below?class Test{ 

a. int mark1; 

b. int mark2; 

c. float avg; 

d. char name[10];}; 


Ans- 22 Bytes  


Que- Which keyword among the following can be used to declare an array of objects in java? 

a. new 

b. create 

c. allocate 

d. arr 


Ans- new  


Que- When is the memory allocated for an object gets free? 

a. At termination of program 

b. When object goes out of scope 

c. When main function ends 

d. When system restarts 


Ans- When object goes out of scope  


Que- Which among the following keyword can be used to free the allocated memory for an object? 

a. delete 

b. free 

c. either delete or free 

d. only delete 


Ans- either delete or free  


Que- Which function is called whenever an object goes out of scope? 

a. Destructor function 

b. Constructor function 

c. Delete function 

d. Free function 


Ans- Destructor function  


Que- Which operator can be used to check the size of an object? 

a. sizeof(objectName) 

b. size(objectName) 

c. sizeofobject(objectName) 

d. sizedobject(objectName) 


Ans- sizeof(objectName)  


Que- The memory allocated for an object ____________________ 

a. Can be only dynamic 

b. Can be only static 

c. Can be static or dynamic 

d. Can't be done using dynamic functions 


Ans- Can be static or dynamic  


Que- If an object is declared in a user defined function __________________ 

a. Its memory is allocated in stack 

b. Its memory is allocated in heap 

c. Its memory is allocated in HDD 

d. Its memory is allocated in cache 


Ans- Its memory is allocated in stack  


Que- In java, ____________________ takes care of managing memory for objects dynamically. 

a. Free collector 

b. Dust collector 

c. Memory manager 

d. Garbage collector 


Ans- Garbage collector  


Que- Which operator can be used to free the memory allocated for an object in C++? 

a. Free() 

b. delete 

c. Unallocate 

d. Collect 


Ans- delete  


Que- What is array of objects? 

a. An array of instances of class represented by single name 

b. An array of instances of class represented by more than one name 

c. An array of instances which have more than 2 instances 

d. An array of instances which have different types 


Ans- An array of instances of class represented by single name  


Que- Which among the following is a mandatory condition for array of objects? 

a. All the objects should be of different class 

b. All the objects should be of same program classes 

c. All the objects should be of same class 

d. All the objects should have different data 


Ans- All the objects should be of same class  


Que- What is the type of the elements of array of objects? 

a. Class 

b. Void 

c. String 

d. Null 


Ans- Class  


Que- If array of objects is declared as given below, which is the limitation on objects?Class_name arrayName[size]; 

a. The objects will have same values 

b. The objects will not be initialized individually 

c. The objects can never be initialized 

d. The objects will have same data 


Ans- The objects will not be initialized individually  


Que- Which is the condition that must be followed if the array of objects is declared without initialization, only with size of array? 

a. The class should have separate constructor for each object 

b. The class must have no constructors 

c. The class should not have any member function 

d. The class must have a default or zero argument constructor 


Ans- The class must have a default or zero argument constructor  


Que- When are the array of objects without any initialization useful? 

a. When object data is not required just after the declaration 

b. When initialization of object data is to be made by the compiler 

c. When object data doesn't matter in the program 

d. When the object should contain garbage data 


Ans- When object data is not required just after the declaration  


Que- If constructor arguments are passed to objects of array then ____________ if the constructors are overloade

d. 

a. It is mandatory to pass same number of arguments to all the objects 

b. It is mandatory to pass same type of arguments to all the objects 

c. It is not mandatory to call same constructor for all the objects 

d. It is mandatory to call same constructor for all the constructors 


Ans- It is not mandatory to call same constructor for all the objects  


Que- How the objects of array can be denoted? 

a. Indices 

b. Name 

c. Random numbers 

d. Alphabets 


Ans- Indices  


Que- The objects in an object array _______________________ 

a. Can be created without use of constructor 

b. Can be created without calling default constructor 

c. Can't be created with use of constructor 

d. Can't be created without calling default constructor 


Ans- Can be created without calling default constructor  


Que- The Object array is created in _____________________ 

a. Heap memory 

b. Stack memory 

c. HDD 

d. ROM 


Ans- Heap memory  


Que- If an array of objects is of size 10 and a data value have to be retrieved from 5th object then ________________ syntax should be use

d. 

a. Array_Name[4].data_variable_name; 

b. Data_Type Array_Name[4].data_variable_name; 

c. Array_Name[4].data_variable_name.value; 

d. Array_Name[4].data_variable_name(value); 


Ans- Array_Name[4].data_variable_name;  


Que- Can we have two dimensional object array? 

a. Yes, always 

b. Yes, only if primitive type array 

c. No, since two indices are impossible 

d. No, never 


Ans- Yes, always  


Que- From which index does the array of objects start? 

a. 0 

b. 1 

c. 2 

d. 3 


Ans- 0  


Que- Is an array of characters always a string? 

a. Yes, always 

b. Yes, if each character is terminated by null 

c. No, since each character is terminated by null 

d. No, never 


Ans- No, never  


Que- Which among the following is main use of object? 

a. To create instance of a function 

b. To create instance of a program 

c. To create instance of class 

d. To create instance of structures 


Ans- To create instance of class  


Que- Which among the following is not a property of an object? 

a. Identity 

b. Properties 

c. Attributes 

d. Names 


Ans- Names  


Que- What is function object? 

a. An object with a single function 

b. An object with only functions 

c. An object with more than one function 

d. An object with no functions 


Ans- An object with a single function  


Que- Immutable object are used ______________________ 

a. To set up as a fixed state 

b. To set up variable object 

c. To set up an object of abstract class 

d. To set up an object of derived class 


Ans- To set up as a fixed state  


Que- Which object can be used to contain other objects? 

a. First class object 

b. Derived class object 

c. Container object 

d. Enclosure object 


Ans- Container object  


Que- A factory object is used ______________________ 

a. To create new classes 

b. To create new function 

c. To create new data members 

d. To create new objects 


Ans- To create new objects  


Que- What are singleton objects? 

a. The only two objects of a class throughout the program 

b. The only object of a class throughout the program 

c. The objects that are alive throughout the program 

d. The objects that are created and then deleted without use 


Ans- The only object of a class throughout the program  


Que- Object cout and cin _________________ 

a. Can be used directly with << and >> symbols respectively 

b. Can be used directly with >> and << symbols respectively 

c. Must be used as a function which accepts 2 arguments 

d. Must be used as a function which accepts 3 arguments 


Ans- Can be used directly with << and >> symbols respectively  


Que- Objects type ____________________ 

a. Can be changed in runtime 

b. Can't be changed in runtime 

c. Can be changed in compile time 

d. May or may not get changed 


Ans- Can't be changed in runtime  


Previous Post Next Post