You are on page 1of 10

1.

C# interview Question- Part 2


2. 1) What is a process and threads?
A process is an entity which has its own memory space and maintain state information.
Thread is an independent execution path, able to run simultaneously with other threads
2) What is an indexer in C#?
A special kind of operator overloading is indexer(). Once the indexer has been defined
3) What is the advantage of using generics in C#?
It is not required to test on data types
It performs sorting much better
Generic delegates can also be used in dynamically generated code without requiring t
4) What is the advantage of using delegates in C#?
They are managed function pointers.
They are type checked and held in spaces that can be reclaimed by the memory manager.
5) Code written in C# can not used in which of the languages?
Code written in C# cannot be used in java.
6) what is object pooling?
The great advantage of using .NET is that it helps to write code to pool objects and
7) Explain about 'this' and where and when it should be used?
This keyword is used to refer to the current class instance. It provides support whil
8) What is a pre-requisite for connection pooling?
All the process should accept to share the same connection, parameters and including
9) Explain ACID rule of thumb for transactions?
All transaction to be automatic, each single unit should be independent, consistent,
10) What is IL?
IL stands for Intermediate language. C# compiler converts the program into intermedia
11) Is it possible to have different access modifiers on the get/set methods of a property?
No, it is not possible to have different access modifier. If the user require to have
12) How to compare two strings in C#?
In general strings can be compared using == and != operators. The following compariso
13) What do you know about .NET assemblies?
Assemblies are smallest unit based on which the development and deployment of .NET ap
14) How do you mark a method absolete?
[Obselete] public int Spy{} {..}
15) How is method overriding different from overloading?
In overriding you change the behavior of a derived class. Overload is to have the same
16) What is boxing?
Encapsulating a copy of a value type in an object is termed as boxing.
17) How does assembly versioning in .NET prevent DLL Hell?
.NET allows assemblies to specify the name AND the version of any assemblies they need
18) What is the difference between const and static read-only?
The major difference is that static variable can be modified by the class which cont
19) Explain the three services model commonly know as a three-tier application.
Presentation
Business
Data
20) How do I convert a string to an int in C#?
using System;
class conversion
{
public static void Main()
{
String s1 = "100";
int y = Convert.ToInt32(s1);
Console.WriteLine(y);
}
}
21) Does C# support templates?
No, C# doesn’t support templates. They support a type of template known as generic. I
22) Why does my Windows application pop up a console window every time I run it?
The properties setting should be in windows application and not console application.
23) Does C# support C type macros?
C# doesn’t support c type macros. Some of the predefined C macros is also defined in
24) Can you declare the override method static while the original method is non-static?
Signature of the virtual method remains the same. The virtual keyword alone is chang
25) How can I get the ASCII code for a character in C#?
Casting the char to an int will give you the ASCII value:
char c = f ;
System.Console.WriteLine((int)c);
If you what to get a char ASCII value which is in a string then the following syntax can be
For Example:- S= Programming
System.Console.WriteLine((int)s[3]);//s[3] returns the ACSII value of ‘g’
The base class libraries also offer ways to do this with the Convert class or Encoding clas

C Interview Question-Part 2
1) What is static variable?
Static variable are constant variable whose value remain the same throughout the progr
2) How can you determine the size of an allocated portion of the memory?
The malloc or free implementation would determine the size of the memory easily.
3) Why do we use structure?
Structures are used for various purpose
* Use of structure variable
* To develop individual array.
4) Define these functions fopen(), fread(), fwrite() and fseek()?
Fopen():- function to open a file, the pointer points to the first record in the file.
Fread():- it reads the file were the pointer is pointing.
Fseek():- This function enables to move from one record to another.
Fwrite:- This function write data in the file were the pointer is pointing.
5) What are logical operators in C?
Logical operators in C are AND and OR operator.
AND denoted by && for example exp1&& exp2
OR denoted by || for example exp1||exp2
6) What is enum used for and state its format?
Enum creates a sequence of integer constant. It is optional to use the name in the enu
7) what is ternary operator?
This operator return the value based on the evaluation of the expression.
General format:-
(expr 1) ? true: false
It is similar to if else construct.
8) Can u write c program without using main function?
Without the main function the program will not be executed. The compiler starts compil
9) What is the use of main function?
The main function invokes other function within it. It is first function during the ex
10) Is c a structural language?
No C is a procedural language. An example of structural language is COBOL.
11) What are the rules for constructing the real constant?
* A real constant should have atleast one digit
* It should be a decimal point
* By default it is assigned positive value
* Within real constant no blank space or commas.
12) The following variable is available in xyz.c, who can access it?:
Static float score
All the functions that contained in the file can access the variable.
13) Disadvantage of using pointers?
The major disadvantage of using pointers is that hackers easily identify source code
14) Why do we use void main() in C language?
The program starts its execution from void main function. Every function in the pr
15) How can I convert number into string?
Number can be converted into string by using the itoa() function. Sprintf can also b
16) What are the advantages of the functions?
•Testing is much easier
•More readability
•Improves the performance of the program
•Reduce the program size.
•Understanding the logic quiet easy.
17) Difference between internal and external static?
Static variable declared internally within the static class and have scope within the
18) Are pointers integers?
Pointers represents the address and it is merely holds a positive value.
19) Can a file other then abc.h be included with #include?
Whatever file specified in the # include the preprocessor would include it. It is alwa
20) what is static identifier?
Static variable represents local variable and it remains in the memory even after the
21) what is static identifier?
Static variable represents local variable and it remains in the memory even after the
22) What are the advantages of the automated variable?
Auto variable can be used in different blocks.
Efficient use of memory.
Variables are protected.
23) What is the use of clrscr()?
Clscr() is a function creates a black screen that creates an impression of clearing t
24) What is the difference between far and near?
Near pointer operates under 64 kilo bytes and far pointer operates under 16 kilo byte
25) What is size of operator?
Size of operator is to obtain the size of the operand. Format of size of operator Siz

C++ interview Question- Part 1


1) What is namespace?
Namespace group a set of functions, classes and objects globally. It splits the global
2) What is encapsulation?
Wrapping up of functions and data into single unit is called encapsulation. The data d
3) What is the difference between Class and structure?
Structure used to bundle data’s of different data types to perform a particular functi
The major difference is that any variable declared inside the structure is public whereas a
4) What is the difference between C and C++?
* C++ is object oriented programming whereas C is structured programming
language.
* C++ uses bottom up approach whereas C uses top down approach.
* In C++ data’s are secured, in C data’s are not secured.
* C doesn’t support namespace.
5) What is polymorphism?
Poly stands for “many” and morph stands for “form”. It simply means the ability of an
6) Give two examples of polymorphism?
Examples of polymorphism are
Function overloading
Function overriding
7) List any two differences between C++ and java?
Java supports interface whereas C++ doesn’t support interface.
Java doesn’t support multiple inheritance it make use of the interface.
8) What do you mean by inline functions?
Inline functions are functions where the call is made to the inline functions.
General format:-
inline datatype function_name(arguments)
9) What is scope resolution operator?
A scope resolution operator denoted by ( ::) is used to define the member functions of
10) What is function overriding?
A function which uses the same name, number and argument type which is used to redefin
11) What is function overloading?
Two methods having the same name and containing different argument is called function
12) Write a program for function overloading?
#include<conio.h>
#include<iostream.h>
class maths {
public:
void square(int num1)
{
cout<<" Square of a given number: " <<num1*num1 <<endl;
}
void square(int num1, int num2 )
{
cout<<" Square of a given number: " <<num1*num2 <<endl;
}
};
void main() //begin of main function
{
clrscr();
maths m;
m.square(5);
m.square(6,7);
getch();
}
The two function with the same function name “square”. Depending on the number of argumen
13) What do you mean by pure virtual function?
A class that contains virtual function is called as abstract class. They are initializ
14) What is the difference between realloc() and free()?
Free() function is used to free the memory space that allocated by malloc() or calloc()
Realloc() function is to resize the memory.
15) What is template?
Template is used to create function that could parameters of any type and return value.
General declaration of template:-
template <Class identifier> function_declaration;
template <typename identifier>function_declaration;
16) What are constructor and destructor in C++?
C onstructor s are special kind of block statement called either when the object created or
Destructor is used to deallocate memory and clean up the class objects and members when the
17) Example of constructor and destructor?
Class student{
Public:
//Consturctor for class student
student();
//destructor for class student
~ student();
};
18) What is RTTI?
RTTI stands for Runtime type information. It is used to keep the information of the ob
19) What is inheritance?
Inheritance helps to a class to reuse the behavior and state of another class. The cla
20) What are C++ storage classes?
Storage class helps to determine whether the variable accessible locally or globally.
Storage classes are
* auto
* register
* static
* extern
21) What is the use of using declaration?
A using declaration makes it possible to use a name from a namespace without the scop
22) What is multiple inheritance?
Multiple inheritance is a feature of object oriented programming language in which a
23) What are the disadvantages of copy constructor?
* It takes a longer time to copy the pointer variable.
* The major disadvantage is that it will copy when it is not required.
24) What is an object?
An object is an instance of a class. It consists of data and functions that can opera
25) What is a friend function?
A friend function use to access the non-public member of a class. It is a member of a

C# interview Question- Part 1


1) What’s the advantage of using System.Text.StringBuilder over System.String?
Strings are object which cannot be modified once created. Each time when the string is
2) Can you store multiple data in System.Array?
Using System.Array to store multiple data types is not possible. In case if the user is
3) What’s a delegate?
A delegate is a type-safe object which can point to another method or multiple methods
A delegate consist of
Method name
Argument (if any)
Return value (if any)
4) What is hashtable?
Hashtable is a .NET datatype that helps in retrieval of data using a unique key.
5) Can multiple catch blocks be executed?
It is not possible to execute multiple catch block. Since once the catch code fires the
6) What are advantages of Microsoft-provided data provider classes in ADO.NET?
It is able to handle single tier to multi-tier.
Provides data security.
They perform task faster.
7) What is an interface class?
Interface class specify the methods, properties and events but they don’t provide imple
8) Can you inherit multiple interfaces?
Multiple interface cannot be implemented using .NET. since .NET doesn’t support interfa
9) What is an abstract class?
Abstract class is a class that cannot be instantiated. It is a class to be inherited and
10) What’s a multicast delegate?
A delegate that has multiple handlers assigned to it. Each assigned handler (method) is
11) What does the term immutable mean?
Immutable refers to data values which cannot be changed.
12) What is difference between of the C and C#?
C is not case sensitive but C# is sensitive.
C# focus more on design and C is on function.
C# is object oriented and C is structured language.
C# is type safe but C is not.
13) What is the difference between C# and java?
Java is cross platform language and C# is window specific language.
C# relies on windows system foundation whereas java rely on java virtual machine.
JVM converts byte code into executable code. C# converts into MSIL.
14) What is the syntax to inherit from a class in C#?
Class newclass: baseclass
Class can be inherited by placing the class name after the colon.
15) What is Microsoft.Access?
Microsoft.Access is used to connect to database inorder to access them.
16) How to Do File Exception Handling in C#?
Exception handling is a built in mechanism in .NET framework. It enables to identify er
17) What’s the difference between // comments, /* */ comments and /// comments?
// comment is used to said single comment.
/* */ Comment is used for multiple line comment.
/// comment is for XML documentation comment.
18) How can you sort the elements of the array in descending order?
Sorting the elements in the descending order can be done by the function sort() and th
19) How’s the DLL Hell problem solved in .NET?
Assembly versioning specify the library that required by the application to run and al
20) What is the use of serializable keyword in C#?
Declaring a class with the keyword serializable enables the object to be serialized ma
21) Pointers in c#?
C# supports pointers but it required to be specified within the unsafe code.
For example
Unsafe
{
// usage of pointers
}
22) How does C# implement events?
C# implements events by the following:-
Pointers
Delegates
DLLs
23) What does assert() do?
Assert taken the parameter in Boolean condition, while debugging it shows the error di
23) What is the name of C#.NET compiler?
C#.NET compiler is JIT(Just in time) compiler.
24) What is true about readonly variable in C# code?
Read only file is to be initialized at the time of the construction of the object.
25) What is shadowing?
Shadowing is a VB.NET concept which can implement base class without overriding the m

C++ interview Question- Part 2


1) Can main be overridden()?
Main() cannot be overridden. It is not a member of any class and hence cannot be over
2) What is stack memory?
Stack memory is a temporary memory, after the execution of the program, no longer the
3) What is heap memory?
Heap memory are permanent memory, the memory allocated for object is maintained even
4) What is abstractor in C++?
Abstract class is designed specially to develop base class. An abstract class contains
5) How to define and use friend function in C++?
It is defined like any other function. Except it should use the keyword friend.
Declaration:-
friend int system(exercise e1)
6) Does C++ have default constructor?
C++ provides default constructor that initialize all the members of the class to NULL v
7) What is a container class?
A class which could hold the objects in memory is called container class. It act as a g
8) What are the types of container classes?
Container class is of two types
Heterogeneous container: - Group of mixed object
Homogeneous container:- holding a group of same objects.
9) Access level in C++?
C++ consist of three important access level. They are as follows:-
Public
Private
Protected.
10) What is a class?
A class is definition of an object.
Defining the class
Class {
//member
}
11) What is auto keyword?
Variable declared with auto will be visible only with the block in which it is declared
12)What is Public, private and protected specifiers?
Public:- data and function inside the public accessible outside the class
Private:- Private data members and function accessible only within the class cannot be acce
Protected:- data member and function accessed only my derived classes.
13) What is the output of printf(“%d”)?
It would print the garbage value.
14) What is the difference between declaration and definition?
Declaration highlights the compiler, at later point will the declaration will be defined.
15) What are the advantages of inheritance?
* Reusability
* It increase the readability of the program
* Reusability reduces the problem after the system is into function.
16) Difference between array and list?
* An array is a collection of homogenous element whereas a list is a collection of hete
* Memory allocated is static and continuous whereas list are random and dynamic
17) What is copy constructor?
Copy constructor is a method which can accept the object of the same class and copies
18) What are 2 ways of exporting a function from a DLL?
•DLL’s library
•With reference to the function from the DLL instance.
19) What is type conversion?
In a computing program the data required to converted from one type to another and it
20) What is the difference between char a[] = “string”; and char *p = “string”; ?
a[] will have 7 bytes and char *p= “string” is only 4 bytes since it is pointing to t
21) What are the advantages of OOPL?
It represent directly real life objects.
It enables polymorphism.
Encapsulation.
22) What is downcasting?
Casting down the hierarchy requires moving from general to a specific type.
23) What do you mean by analysis and design?
The process of determining the requirement before performing the task, the developer re
Design phase require to choose a particular item and adopt it.
24) What do you meant by active and passive objects?
Active objects are one which an interaction which owns a thread and they are responsibl
Passive objects are one, which passively waits for the message to be processed. It wait
25) What is a modifier?
A modifier is a function that modifies the data in the class.
Modifiers in java are as follows:-
* Abstract
* Final
* Native
* Public
* Protected
* Private
* Static.

You might also like