Machine-translated by Google. Questions are authored in English.
Top

Classes and Objects Questions and Answers

1.

A/An ______ is a user-defined datatype which has data members and member functions.

Exam Year(s)

DSSSB TGT - 2023,

Answer: A

A class is a user-defined data type that holds data members and member functions. An object is an instance of a class, created from it, not the type itself. A package is a way of grouping related classes in languages such as Java, and a method is a single function inside a class. Only the class fits the definition. In Java and C++ the keyword class is used to define such a type, and objects are then created from it.

Please log in or register to report this question.

2.

The structure of C++ programming brings together a group of :

Exam Year(s)

MH SET - 2018, SET Exam - 2018,

Answer: A

A C++ structure brings together related data items, variables.

A struct groups variables that belong together, which may be of different types, under one name: for example a student's roll number (int), name (char array) and marks (float). In C++ a structure can also contain member functions.

Items of the same data type are grouped by an array, not a structure, and integers with user-defined names describe an enumeration (enum). Since those two are wrong, 'All of the above' is wrong too.

Please log in or register to report this question.

Answer: B

A static function can be called using the class name and function name.

A static member function belongs to the class as a whole, not to any particular object. It has no this pointer, can directly access only static members, and is called with the class name and the scope resolution operator, as in Counter::count(), without needing an object.

The function called when an object is destroyed is the destructor. A static function needs no dummy object, which is the whole point, and the statement that it is closely connected with an individual object describes ordinary (non-static) member functions.

Please log in or register to report this question.

4.

In C++ .................. operator is used for Dynamic memory allocation.

Exam Year(s)

MH SET - 2018, SET Exam - 2018,

Answer: C

Dynamic memory is allocated with the new operator.

In C++, new allocates memory on the free store (heap) at run time, constructs the object there, and returns a pointer to it; for example int *p = new int[10];. The memory is released with delete or delete[].

The scope resolution operator :: names a member or global identifier, the conditional operator ?: chooses between two expressions, and the member access operators (dot and arrow) select a member of an object. None of them allocates memory.

Please log in or register to report this question.

Loading…

Other Subjects

Tags: Classes and Objects Questions and Answers || Classes and Objects MCQ Questions and Answers || Classes and Objects GK Questions and Answers || Classes and Objects GK MCQ Questions || Classes and Objects Multiple Choice Questions and Answers || Classes and Objects GK || GK on Classes and Objects || Object Oriented Programming Questions and Answers || Object Oriented Programming MCQ Questions and Answers || Object Oriented Programming GK Questions and Answers || GK on Object Oriented Programming