C++ Interview Question


Prev Tutorial Next Tutorial

C++ Interview Question for Freshers

Basic C++

C++ is object oriented or structure oriented ?

C++ is object oriented programming language.

Why use C++ language ?

C++ is object oriented programming language and it is very simple and easy to wirte. It is more secure than C programming.

C++ is platform dependent language ?

Yes, It is platform dependent language, because it not run on other system with respect to its development. Features of C++

C++ is case sensitive language ?

Yes, C++ is a case sensitive programming language. In C++ programming 'break and BREAK' both are different.

What is keyword ?

Keyword is a predefined or reserved word in C++ library with a fixed meaning and used to perform an internal operation. C Language supports 32 keywords.

What is Constant ?

It is an identifier whose value can not be changed at the execution time of program. In general constant can be used to represent as fixed values in a C++ program.

What is Garbage value ?

Garbage value can be any value given by system and that is no way related to correct programs. It is a disadvantage and it can overcome using variable initialization.
In C++ programming avoid garbage collection by using variable initialization

What is data type ?

Data type is a keyword used to identify type of data. Data types are used for representing the input of the user in the main memory (RAM) of the computer.

What is difference between compiler and interpreter

NoCompilerInterpreter
1Compiler takes Entire program as input at a time.Interpreter takes Single instruction as input at a time.
2Intermediate Object code is generatedNo Intermediate Object code is generated
3It execute conditional control statements fastly.It execute conditional control statements slower than Compiler
4More memory is required.Less memory is required.
5Program need not to be compiled every timeEvery time higher level program is converted into lower level program
6It display error after entire program is checkedIt display error after each instruction interpreted (if any)
7Example: CExample: BASIC

What is buffer in C++

Temporary storage area is called buffer.

Which data type supported by switch case ?

A switch statement work with byte, short, char and int primitive data type, it also works with enumerated types and string.

What is || operator ?

The || is also known as the OR operator in C++ programming. This operator is return true when at least one condition is true.

What is limitations with switch case ?

Logical operators can not be used with switch statement.

Why use getch()

It is a predefined function in "conio.h" (console input output header file) will tell to the console wait for some time until a key is hit given after running of program.

By using this function we can read a character directly from the keyboard. Generally getch() are placing at end of the program after printing the output on screen.

Difference between source code and object code.

Source codeObject code
Source code is in the form of Text form.Object Code is in the form of Binary Numbers.
Source code is Human Readable Code.Object Code is in Machine Readable formats.
Source code is Generated by Human or Programmer.Object Code is Generated by Compiler.
Source code is receive Compiler as a Input.Object Code is Generated by Compiler as a Output.

What is the modulus operator ?

Modulus operator return remainder. The modulus operator is used for get the remainder if you divide any number by other number.

What is Ternary Operator ?

If any operator is used on three operands or variable is known as Ternary Operator. It can be represented with ? : . It is also called as conditional operator.

Main advantage of Ternary operator ?

Using Ternary Operator reduce the number of line codes and improve the performance of application.

What is binary operator ?

Binary operator are used with two operands, example +, _ *, / operators are binary operators/

What is unary operator ?

Unary operators are those which are used with only on single or one operand, example ++, -- are unary operator

Why use Loop ?

Where need repetition of same code a number of times at that place use Loop in place of writing more than one statements. The way of the repetition will be forms a circle that's why repetition statements are called loops.

When use Do-While Loop ?

When we need to repeat the statement block at least 1 time then we use do-while loop.

What is while Loop ?

In while loop First check the condition if condition is true then control goes inside the loop body other wise goes outside the body. while loop will be repeats in clock wise direction.

Difference between while and do..while loop ?

In while loop First check the condition if condition is true then control goes inside the loop body other wise goes outside the body. but in case of do..while loop at least one time loop will be execute then condition is checked.

Which loop have fast execution for or while ?

Execution process of while loop is slower than for loop

Error in C++

What is error in C++ ?

Error is a abnormal condition whenever it occurs execution of the program is stopped these are mainly classified into following types.

  • Compile time error
  • Run time error

What is Compile time error in C++

If any error is generated at the time of compilation is known as compile time error, in general these are raised while break down the rules and regulation of programming language.

What is Run time error in C++

If any error is generated at run time is known as runtime error, in general these are raised because of writing wrong logic in the program.

What is warning in C++

Warning is also an abnormal condition but whenever it occurred execution of program will never be stopped.

Difference between call by value and call by reference.

call by valuecall by reference
This method copy original value into function as a arguments.This method copy address of arguments into function as a arguments.
Changes made to the parameter inside the function have no effect on the argument.Changes made to the parameter affect the argument. Because address is used to access the actual argument.
Actual and formal arguments will be created in different memory locationActual and formal arguments will be created in same memory location

Difference between Structure and Union

StructureUnion
1For defining structure use struct keyword.For defining union we use union keyword
2Structure occupies more memory space than union.Union occupies less memory space than Structure.
3In Structure we can access all members of structure at a time.In union we can access only one member of union at a time.
4Structure allocates separate storage space for its every members.Union allocates one common storage space for its all members. Union find which member need more memory than other member, then it allocate that much space

What is advantage of union over structure ?

It occupies less memory because it occupies the memory of largest member only.

What is disadvantage of union over structure ?

It can store data in one member only.

What is syntax error ?

Whenever any mistake are occurred at the time write programming code.

What is the use of a '\0' character ?

It is referred to as a terminating null character, It is generally used to show the end of a string value.

File Handling

What is FILE ?

FILE is predefined data type, which is defined in stdio.h.

What is NULL in C++ ?

NULL is a macro which is defined in C++ header files. The value of NULL macro is 0.

What is dangling pointer in C++ ?

When a pointer is pointing to non-existing memory location is called dangling pointer.

What are preprocessor directives ?

Preprocessor is a program which will executed automatically before passing the source program to compiler. This process is called pre-processing.

Download Projects

Google Adsense Advertisements

Buy 3 Year Old Domain, Tutorialday.com, SeosmoTools.com @$200

Buy This Ad Space @$50 per Month, Ad Size 300X250 Contact on: hitesh.xc@gmail.com WhatsApp no. 8882538826

Yahoo Advertisements