Explore topic-wise MCQs in Matlab.

This section includes 301 Mcqs, each offering curated multiple-choice questions to sharpen your Matlab knowledge and support exam preparation. Choose a topic below to get started.

201.

In C++, const qualifier can be applied to1) Member functions of a class2) Function arguments3) To a class data member which is declared as static4) Reference variables

A. Only 1, 2 and 3
B. Only 1, 2 and 4
C. All
D. Only 1, 3 and 4
Answer» D. Only 1, 3 and 4
202.

How C++ compiler does differ between overloaded postfix and prefix operators?

A. C++ doesn’t allow both operators to be overloaded in a class
B. A postfix ++ has a dummy parameter
C. A prefix ++ has a dummy parameter
D. By making prefix ++ as a global function and postfix as a member function.
Answer» C. A prefix ++ has a dummy parameter
203.

Class function which is called automatically as soon as the object is created is called as __

A. Constructor
B. Destructor
C. Friend function
D. Inline function.
Answer» B. Destructor
204.

It is possible to define a class within a class termed as nested class. There are _____ types of nested classes.

A. 2
B. 3
C. 4
D. 5
Answer» B. 3
205.

Predict the output?#include using namespace std;class Test{ int x; Test() { x = 5; } };int main(){ Test *t = new Test; cout << t->x;}

A. Compiler Error
B. 5
C. Garbage Value
Answer» B. 5
206.

Which of the following best defines the syntax for template function?

A. Template
B. Template return_type Function_Name(Parameters)
C. Both a and b
D. None of these
Answer» D. None of these
207.

If inner catch handler is not able to handle the exception then__________.

A. Compiler will look for outer try handler
B. Program terminates abnormally
C. Compiler will check for appropriate catch handler of outer try block
D. None
Answer» D. None
208.

A member function can always access the data in __________, (in C++).

A. the class of which it is member
B. the object of which it is a member
C. the public part of its class
D. the private part of its class
Answer» B. the object of which it is a member
209.

#includeusing namespace std;class Point {public: Point() { cout << "Constructor called"; }};int main(){ Point t1, *t2; return 0;}

A. Compiler Error
B. Constructor called Constructor called
C. Constructor called
D. None of the above
Answer» D. None of the above
210.

What is the size of wchar_t in C++?

A. 2
B. 4
C. 2 or 4
D. Based on the number of bits in the system
Answer» E.
211.

What does an escape code represent?

A. alert
B. backslash
C. tab
D. form feed
Answer» B. backslash
212.

Predict the output of following C++ program.#includeusing namespace std;class Empty {};int main() {cout << sizeof(Empty);return 0;}

A. A non-zero value
B. 0
C. Compiler Error
D. Runtime Error
Answer» B. 0
213.

Which of the following is true about virtual functions in C++?

A. Virtual functions are functions that can be overridden in derived class with the same signature.
B. Virtual functions enable run-time polymorphism in a inheritance hierarchy.
C. If a function is ‘virtual’ in the base class, the most-derived class implementation of the function is called according to the actual type of the object referred to, regardless of the declared type of the pointer or reference. In non-virtual functions, the functions are called according to the type of reference or pointer.
D. All of the above
Answer» E.
214.

Attempting to throw an exception that is not supported by a function call results in calling _____________ library function.

A. indeterminate ()
B. unutilized()
C. unexpected()
D. unpredicted()
Answer» D. unpredicted()
215.

Which of the following, in C++, is inherited in a derived class from base class?

A. Constructor
B. Destructor
C. Data members
D. Virtual methods
Answer» D. Virtual methods
216.

When one object reference variable is assigned to another object reference variable then

A. a copy of the object is created.
B. a copy of the reference is created.
C. a copy of the reference is not created.
D. it is illegal to assign one object reference variable to another object reference variable.
Answer» C. a copy of the reference is not created.
217.

Which of the following is true about constructors?1) They cannot be virtual.2) They cannot be private.3) They are automatically called by new operator.

A. All 1, 2, and 3
B. Only 1 and 3
C. Only 1 and 2
D. Only 2 and 3
Answer» C. Only 1 and 2
218.

Which of the following is not correct (in C++)?1. Class templates and function templates are instantiated in the same way2. Class templates differ from function templates in the way they are initiated3. Class template is initiated by defining an object using the template argument4. Class templates are generally used for storage classes

A. (1)
B. (2), (4)
C. (2), (3), (4)
D. (4)
Answer» D. (4)
219.

Which operations don’t throw anything?

A. Operations which are reversible
B. Operations which are irreversible
C. Operations which are static
D. Operations which are dynamic
Answer» C. Operations which are static
220.

Output of following C++ program?#includeusing namespace std;int main(){ int x = 10; int& ref = x; ref = 20; cout << "x = " << x << endl ; x = 30; cout << "ref = " << ref << endl; return 0;}

A. x = 20; ref = 30
B. x = 20; ref = 20
C. x = 10; ref = 30
D. x = 30; ref = 30
Answer» B. x = 20; ref = 20
221.

Which of the following operators should be preferred to overload as a global function rather than a member method?

A. Postfix ++
B. Comparison Operator
C. Insertion Operator <<
D. Prefix++
Answer» D. Prefix++
222.

What do container adapter provide to interface?

A. Restricted interface
B. More interface
C. No interface
D. None
Answer» B. More interface
223.

If a function is friend of a class, which one of the following is wrong?

A. A function can only be declared a friend by a class itself.
B. Friend functions are not members of a class, they are associated with it.
C. Friend functions are members of a class.
D. It can have access to all members of the class, even private ones.
Answer» D. It can have access to all members of the class, even private ones.
224.

Which of the following is incorrect in C++?(1)When we write overloaded function we must code the function for each usage.(2)When we write function template we code the function only once.(3)It is difficult to debug macros(4)Templates are more efficient than macros

A. (1) and (2)
B. (1), (2) and (3)
C. (3) and (4)
D. All are correct.
Answer» E.
225.

Assigning one or more function body to the same name is called ____________.

A. Function Overriding
B. Function Overloading
C. Both A and B
D. None of the above
Answer» C. Both A and B
226.

Which of the following is FALSE about references in C++?

A. References cannot be NULL
B. A reference must be initialized when declared
C. Once a reference is created, it cannot be later made to reference another object; it cannot be reset.
D. References cannot refer to constant value
Answer» E.
227.

At which time does the static_cast can be applied?

A. Compile-time construct
B. Runtime construct
C. Both Compile-time & Runtime construct
D. None
Answer» B. Runtime construct
228.

What happens when delete is used for a NULL pointer?int *ptr = NULL;delete ptr;

A. Compiler Error
B. Run-time Crash
C. No Error
D. None
Answer» D. None
229.

Which of the following statements are true? int f (float)

A. f is a function taking an argument of type int and returning a floating point number
B. f is a function taking an argument of type float and returning an integer
C. f is a function of type float
D. none of the mentioned
Answer» C. f is a function of type float
230.

What is the built in library function to compare two strings?

A. string_cmp()
B. strcmp()
C. equals()
D. str_compare()
Answer» C. equals()
231.

How to create a dynamic array of pointers (to integers) of size 10 using new in C++?Hint: We can create a non-dynamic array using int *arr[10]

A. int *arr = new int *[10];
B. int **arr = new int *[10];
C. int *arr = new int [10];
D. Not Possible
Answer» C. int *arr = new int [10];
232.

Which operators is part of RTTI?

A. dynamic_cast()
B. typeid
C. Both dynamic_cast() & typeid
D. None
Answer» D. None
233.

Which of the following are member dereferencing operators in CPP?1. * 2. :: 3. ->* 4. ::* 5. ->

A. Only 1, 3, 4
B. Only 1 and 5
C. Only 3 and 4
D. Only 3,4,5
Answer» B. Only 1 and 5
234.

When a method in a subclass has the same name and type signatures as a method in thesuperclass, then the method in the subclass _____ the method in the superclass.

A. Overloads
B. Friendships
C. Inherits
D. Overrides
Answer» E.
235.

Which of the following is true about new when compared with malloc:1) new is an operator, malloc is a function2) new calls constructor, malloc doesn’t3) new returns appropriate pointer, malloc returns void * and pointer needs to typecast to appropriate type.

A. 1 and 3
B. 2 and 3
C. 1 and 2
D. All 1, 2 and 3
Answer» E.
236.

Return type of uncaught_exception () is ________________.

A. int
B. bool
C. char *
D. double
Answer» C. char *
237.

Which operation is used as Logical 'AND'

A. Operator-&
B. Operator-
C. Operator-&&
D. Operator +
Answer» D. Operator +
238.

While overloading binary operators using member function, it requires ___ argument/s.

A. Zero
B. One
C. Two
D. Three
Answer» C. Two
239.

Which operator is required to be overloaded as member function only?

A. _
B. _ _
C. ++ (postfix version)
D. 0
Answer» E.
240.

When an ADT is implemented as a C++ class, which of the following should normally betrue?

A. Member functions are private, member variables are public
B. Member functions are public, member variables are private
C. Member functions as well as member variables are private
D. Member functions as well as member variables are public
Answer» C. Member functions as well as member variables are private
241.

The code of statements which may cause abnormal termination of the program should bewritten under_________ block.

A. Try
B. catch
C. Finally
D. None of these
Answer» B. catch
242.

Which of the following in Object Oriented Programming is supported by Function overloading and default arguments features of C++?

A. Inheritance
B. Polymorphism
C. Encapsulation
D. None of the above
Answer» C. Encapsulation
243.

Constructors have _____ return type.

A. void
B. char
C. int
D. no
Answer» E.
244.

Output of following program?#include using namespace std;int fun(int=0, int = 0);int main(){ cout << fun(5);return 0;}int fun(int x, int y){return (x+y);}

A. Compiler Error
B. 5
C. 10
Answer» C. 10
245.

Implicit return type of a class constructor is:

A. not of class type itself
B. class type itself
C. a destructor of class type
D. a destructor not of class type
Answer» C. a destructor of class type
246.

Output of following program?#includeusing namespace std;class Point { Point() { cout << "Constructor called"; }}; int main(){ Point t1; return 0;}

A. Compiler Error
B. Runtime Error
C. Constructor called
D. None of the above
Answer» B. Runtime Error
247.

When a virtual function is redefined by the derived class, it is called___________.

A. Overloading
B. Overriding
C. Rewriting
D. All of these
Answer» C. Rewriting
248.

Which of the following is true about templates?1) Template is a feature of C++ that allows us to write one code for different data types.2) We can write one function that can be used for all data types including user defined types. Like sort(), max(), min(), ..etc.3) We can write one class or struct that can be used for all data types including user defined types. Like Linked List, Stack, Queue,..etc.4) Template is an example of compile time polymorphism.

A. 1 and 2
B. 1, 2 and 3
C. 1, 2 and 4
D. 1, 2, 3 and 4
Answer» E.
249.

When the inheritance is private, the private methods in base class are __________ in thederived class (in C++).

A. inaccessible
B. accessible
C. protected
D. public
Answer» B. accessible
250.

What is the use of this pointer?

A. When local variable’s name is same as member’s name, we can access member using this pointer.
B. To return reference to the calling object
C. Can be used for chained function calls on an object
D. All of the above
Answer» E.