• +91 9723535972
  • info@interviewmaterial.com

CPlusPlus Interview Questions and Answers

CPlusPlus Interview Questions and Answers

Question - 51 : - What is an HTML tag?

Answer - 51 : - Answer: An HTML tag is a syntactical construct in the HTML language that abbreviates specific instructions to be executed when the HTML script is loaded into a Web browser. It is like a method in Java, a function in C++, a procedure in Pascal, or a subroutine in FORTRAN.

Question - 52 : - What problems might the following macro bring to the application?

Answer - 52 : - #define sq(x) x*x

Question - 53 : - Anything wrong with this code? T *p = new T[10]; delete p;

Answer - 53 : - Everything is correct, Only the first element of the array will be deleted”, The entire array will be deleted, but only the first element destructor will be called.

Question - 54 : - Anything wrong with this code? T *p = 0; delete p;

Answer - 54 : - Yes, the program will crash in an attempt to delete a null pointer.

Question - 55 : - How do you decide which integer type to use?

Answer - 55 : - It depends on our requirement. When we are required an integer to be stored in 1 byte (means less than or equal to 255) we use short int, for 2 bytes we use int, for 8 bytes we use long int. A char is for 1-byte integers, a short is for 2-byte integers, an int is generally a 2-byte or 4-byte integer (though not necessarily), a long is a 4-byte integer, and a long long is a 8-byte integer.

Question - 56 : - What does extern mean in a function declaration?

Answer - 56 : - Using extern in a function declaration we can make a function such that it can used outside the file in which it is defined. An extern variable, function definition, or declaration also makes the described variable or function usable by the succeeding part of the current source file. This declaration does not replace the definition. The declaration is used to describe the variable that is externally defined. If a declaration for an identifier already exists at file scope, any extern declaration of the same identifier found within a block refers to that same object. If no other declaration for the identifier exists at file scope, the identifier has external linkage.

Question - 57 : - What can I safely assume about the initial values of variables which are not explicitly initialized?

Answer - 57 : - It depends on complier which may assign any garbage value to a variable if it is not initialized.

Question - 58 : - What is the difference between char a[] = “string”; and char *p = “string”;?

Answer - 58 : - In the first case 6 bytes are allocated to the variable a which is fixed, where as in the second case if *p is assigned to some other value the allocate memory can change.

Question - 59 : - How many ways are there to initialize an int with a constant?

Answer - 59 : - Two. There are two formats for initializers in C++ as shown in the example that follows. The first format uses the traditional C notation. The second format uses constructor notation. int foo = 123; int bar (123);

Question - 60 : - How many ways are there to initialize an int with a constant?

Answer - 60 : - Two. There are two formats for initializers in C++ as shown in the example that follows. The first format uses the traditional C notation. The second format uses constructor notation. int foo = 123; int bar (123);


NCERT Solutions

 

Share your email for latest updates

Name:
Email:

Our partners