Monday 9 September 2013

NMIMS Management Aptitude Test (NMAT) Sample Paper


LANGUAGE SKILLS

 

This is a test to see how well you ‘know’ English. Your English language ability would be tested through questions on functional grammar, vocabulary, sentence completion, synonyms, antonyms, comprehension of a passage, etc. Study and answer the sample questions given below. Please remember, in the test proper there may be questions of several other types also. 

Sunday 8 September 2013

Unsafe to deal locate the memory using free( ) if it has been allocated using new

Why it is unsafe to deal locate the memory using free( ) if it has been allocated using new?

assert( ) macro...

assert( ) macro...

We can use a macro called assert( ) to test for conditions that should not occur in a code. This                               macro expands to an if statement. If test evaluates to 0, assert prints an error message and                               calls abort to abort the program. 

                             #include
                             #include

                             void main( )                              {
                             int i ;
                             cout << "\nEnter an integer: " ;                              cin >> i ;
                             assert ( i >= 0 ) ;                              cout << i << endl ;
                             }

Reference as a data member of a class

Can I have a reference as a data member of a class? If yes, then how do I initialise it?

Ans: 


Yes, we can have a reference as a data member of a class. A reference as a data member of a  class is initialised in the initialisation list of the constructor. This is shown in following program.
                             #include

                             class sample                              {
                             private :
                             int& i ;
                             public :
                             sample ( int& ii ) : i ( ii )
                             {                              }
                             void show( )                              {
                             cout << i << endl ;
                             }
                             } ;
                             void main( )                              {
                             int j = 10 ;                              sample s ( j ) ;                              s.show( ) ;
                             }

Here, i refers to a variable j allocated on the stack. A point to note here is that we cannot bind a reference to an object passed to the constructor as a value. If we do so, then the reference i  would refer to the function parameter (i.e. parameter ii in the constructor), which would  disappear as soon as the function returns, thereby creating a situation of dangling reference.

What is strstream

What is strstream?

Ans:
 


strstream is a type of input/output stream that works with the memory. It allows using section of the memory as a stream object. These streams provide the classes that can be used for storing the stream of bytes into memory. For example, we can store integers, floats and strings as a stream of bytes.

There are several classes that implement this in-memory formatting. The class ostrstream derived from ostream is used when output is to be sent to memory, the class istrstream derived from istream is used when input is taken from memory and strstream class derived from iostream is used for
memory objects that do both input and output.

pointer inside static member function

Can we use this pointer inside static member function?

Ans:
 


No! The this pointer cannot be used inside a static member function. This is because a static member function is never called through an object.

istream class

What is the purpose of istream class?

Ans:
The istream class performs activities specific to input. It is derived from the ios class. The most commonly used member function of this class is the overloaded >> operator which can extract values of all basic types. We can extract even a string using this operator.

What is the limitation of cin while taking input for character array

What is the limitation of cin while taking input for character array?

Ans: 


To understand this consider following statements, 

                             char str[5] ;
                             cin >> str ; 


While entering the value for str if we enter more than 5 characters then there is no provision in
 cin to check the array bounds. If the array overflows, it may be dangerous. This can be  avoided by using get( ) function. For example, consider following statement, 

                             cin.get ( str, 5 ) ;

nocreate and noreplace flag

What do the nocreate and noreplace flag ensure when they are used for opening a file?
Ans: 


nocreate and noreplace are file-opening modes. A bit in the ios class defines these modes. The flag nocreate ensures that the file must exist before opening it. On the other hand the flag noreplace ensures that while opening a file for output it does not get overwritten with new one  unless ate or app is set. 

When the app flag is set then whatever we write gets appended to the existing file. When ate flag is set we can start reading or writing at the end of existing file.

What are put and get pointers

What are put and get pointers?
Ans: These are the long integers associated with the streams. The value present in the put pointer specifies the byte number in the file from where next write would take place in the file. The get pointer specifies the byte number in the file from where the next reading should take place.

How do I get the current position of the file pointeR

How do I get the current position of the file pointer?

Ans:
 


We can get the current position of the file pointer by using the tellp( ) member function of ostream class or tellg( ) member function of istream class. These functions return (in bytes)positions of put pointer and get pointer respectively.
What is the difference between the manipulator and setf( ) function?
Ans: 


The difference between the manipulator and setf( ) function are as follows: 

The setf( ) function is used to set the flags of the ios but manipulators directly insert the formatting instructions into the stream. We can create user-defined manipulators butsetf( ) function uses data members of ios class only. The flags put on through the setf( ) function can be put off through unsetf( ) function. Such flexibility is not available with manipulators.