JECA Mock2 (Object Oriented Programming) - 2023-06-13
JECA Mock2 (Object Oriented Programming) - 2023-06-13
Logged in as Student
Saturday 17th Jun, 2023 05:04:08 PM
Search Student
JECA Joint Entrance Exam MCA (WB
Section : J-1st_Sem 2022 Course :
Academics and Personal Info JECA)
View Marks
Group A (Object Oriented Programming): Answer All question(s)
Submit Assignments 1. Object being passed to a copy constructor ___________ Marks: 1 (Correct: a)
Knowledge Assessment a) Must be passed by b) Must be passed by c) Must be passed with d) Must not be mentioned
reference value integer type in parameter list
View Books
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 will be called, and this will keep on calling itself. This will cause the compiler to give out of memory error.
View Timetable
2. Which among the following best describes encapsulation? Marks: 1 (Correct: d)
Download Class Materials c) It is a way of combining d) It is a way of combining
a) It is a way of combining b) It is a way of various data members and various data members
View Previous Questions various data members into a combining various member member functions into a and member functions
single unit functions into a single unit single unit which can operate that operate on those data
on any data members into a single unit
Submit Course Feedbacks
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 it a 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.
3. What is the additional feature in classes that was not in structures? Marks: 1 (Correct: b)
a) Data members b) Member functions c) Static data allowed d) Public access specifier
Explanation: Member functions are allowed inside a class but were not present in structure concept. Data members, static data and
public access specifiers were present in structures too.
4. Which among the following is true for copy constructor? Marks: 1 (Correct: b)
a) The argument object is b) It can be defined with zero c) Used when an object is d) Used when a function
passed by reference arguments passed by value to a function returns an object
Explanation: It can’t be defined with zero number of arguments. This is because to copy one object to another, the object must be
mentioned so that compiler can take values from that object.
Explanation: A temporary object is created to return the value. It is created because the object used in function is destroyed as soon as
the function is returned. The temporary variable returns the value and then gets destroyed.
6. Which specifier allows a programmer to make the private members which can be Marks: 1 (Correct: c)
inherited?
a) Private b) Default c) Protected d) Protected and default
Explanation: Protected access is used to make the members private. But those members can be inherited. This gives both security and
code reuse capability to a program.
7. In which access should a constructor be defined, so that object of the class can be Marks: 1 (Correct: a)
created in any function?
d) Any access specifier
a) Public b) Protected c) Private
will work
Explanation: Constructor function should be available to all the parts of program where the object is to be created. Hence it is advised
to define it in public access, so that any other function is able to create objects.
d) Anytime when
a) Just before end of program b) Just after end of program c) With the end of program
object is not needed
Explanation: This is because the lifespan of global object is from start of the program, till the end of the program. And hence program
end is the end of global object too. Just before the end of program, the destructor will be called to free the acquired resources by the
objects.
9. What is size of the object of following class (64 bit system)? Marks: 1 (Correct: c)
a) 20 b) 22 c) 24 d) 28
Explanation: The size of any object of student class will be of size 4+20=24, because static members are not really considered as
property of a single object. So static variables size will not be added.
Explanation: The object should not be modified in the copy constructor. Because the object itself is being copied. When the object is
returned from a function, the object must be a constant otherwise the compiler creates a temporary object which can die anytime.
11. Which feature in OOP is used to allocate additional function to a predefined Marks: 1 (Correct: a)
operator in any language?
a) Operator Overloading b) Function Overloading c) Operator Overriding d) Function Overriding
Explanation: 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.
Explanation: The constructor is called as soon as the object is created. The overloading comes into picture as to identify which
constructor have to be called depending on arguments passed in the creation of object.
Explanation: The object declared in main() have local scope inside main() function only. It can’t be used outside main() function. Scope
resolution operator is used to access globally declared variables/objects.
Explanation: The keyword explicit can be used while defining the constructor only. This is used to suppress the implicit call to the
constructor. It ensures that the constructors are being called with the default syntax only (i.e. only by using object and constructor
name).
15. Which feature of OOP is indicated by the following code? Marks: 1 (Correct: d)
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 overloaded.
Explanation: While returning an object we can use the copy constructor. When we assign the return value to another object of same
class then this copy constructor will be used. And all the members will be assigned the same values as that of the object being returned.
Explanation: First the constructor of parent class are called. The order in which the parent class constructors are called is same in the
sequence of inheritance used.
a) Class and object b) Class and structure c) Structure and object d) Structure and functions
Explanation: Class and structure are similar to each other. Only major difference is that a structure doesn’t have member functions
whereas the class can have both data members and member functions.
Explanation: Classes are pass by reference, and the structures are pass by copy. It doesn’t depend on the program.
20. Which Feature of OOP illustrated the code reusability? Marks: 1 (Correct: d)
a) Polymorphism b) Abstraction c) Encapsulation d) Inheritance
Explanation: Using inheritance we can reuse the code already written and also can avoid creation of many new functions or variables,
as that can be done one time and be reused, using classes.
21. If programmer doesn’t define any copy constructor then _____________ Marks: 1 (Correct: a)
d) The program gives run
a) Compiler provides an c) The objects can’t be
b) Compiler gives an error time error if copying is
implicit copy constructor assigned with another objects used
Explanation: The compiler provides an implicit copy constructor. It is not mandatory to always create an explicit copy constructor. The
values are copied using implicit constructor only.
22. A phone is made up of many components like motherboard, camera, sensors and Marks: 1 (Correct: d)
etc. If the processor represents all the functioning of phone, display shows the display
only, and the phone is represented as a whole. Which among the following have
highest level of abstraction?
Explanation: Phone as a whole have the highest level of abstraction. This is because the phone being a single unit represents the
whole system. Whereas motherboard, display and camera are its components.
23. Which class can have member functions without their implementation? Marks: 1 (Correct: d)
Explanation: Abstract classes can have member functions with no implementation, where the inheriting subclasses must implement
those functions.
Explanation: The array must be specified with a size. You can’t declare object array, or any other linear array without specifying its size.
It’s a mandatory field.
25. When OOP concept did first came into picture? Marks: 1 (Correct: a)
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, SmallTalk was first language to use pure OOP and followed all rules strictly.
Explanation: Classes doesn’t have any size, actually the size of object of the class can be defined. That is done only when an object is
created and its constructor is called.
class student
void disp()
};
public :
void disp()
s.disp();
t.disp();
a) Its base classIts derived b) Its base class Its derived c) Its derived classIts base d) Its derived class Its
class class class base class
Explanation: You need to focus on how the output is going to be shown, no space will be given after first message from base class. And
then the message from derived class will be printed. Function disp() in base class overrides the function of base class being derived.
28. Which class/set of classes can illustrate polymorphism in the following code? Marks: 1 (Correct: c)
calc_grade();
public : calc_grade()
return 10;
};
public : calc_grade()
return 20;
};
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_grade(); 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.
Explanation: The destructor is never called in this situation. The concept is that when an 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.
Explanation: Kotlin language allows constructor overloading. This is a basic feature for the constructors. The constructor overloading
allows the object to be initialized according to the user.
Back