Dynamic Binding | Static Binding | ||
|
|
What is the difference between Dynamic and Static Binding?
What is Data hiding or Information Hiding?
Data hiding means hiding class data which is also known as Member data from outside classes. C++ uses access modifiers and encapsulation to implement Data hiding. For eg; Data declared in private section is not accessible to other classes. Whereas data declared in protected section is also not accessible to other classes except the Derived class.
What is a Class?
Class is a grouping of the objects which are similar to each other. We can create any number of objects of a class. Class consists of data and functions. Data of a class is known as Member Data and functions of a class are known as Member functions. No memory space is allocated to a Class.
For eg: Vehicle is an example of class which has scooter, car, bicycle etc as its objects.
What is a macro in C?
Macros are used to define constants values of variables. The value which we assign to a variable by using macro makes it a constant and we can use that variable anywhere in the program. In order to change the value of the variable we can change it its macro declaration rather than changing its value everywhere in the program where that variable is used.
Eg.:
#define pie 3.142 //Defining a Macro
Void main ()
{
Int r;
Float ar;
Printf (“Enter radius”);
Scanf(“%d”, &r);
Ar= pie*r*r;
Printf(“Area is %f”,ar);
Getch();
}
What are Local and Global Variables?
Local variables: The variables which are defined inside a particular function are known as Local variables. These local variables can be used only within that particular function but outside that function these variables are not accessible.
Global Variables: The variables which are not defined inside a particular function rather they are defined outside all the functions are called Global variables. These variables can be accessed from each and every part of the program as these are accessible to all the functions of a program.
What is Structure?
Structure is used to store data items or values of different data types or in other words structures are used to store records. Unlike an array which can store data of similar data type, structure can store data of different data types.
Syntax:
Struct variable
{
data_type variable1;
data_type variable2;
data_type variable n;
}
What are Strings?
String is defined as an array of characters in C. Last character of the string is a Null character (‘\0’) which specifies the end of string and has a decimal value 0.
Eg: char name [7] = {‘s’,’a’,’c’,’h’,’i’,’n’,’\0’};
What are comments?
Comments are written in source code (source program) for documentation purpose as while compiling, the compiler discards these comments from the code. Its main usage is to give descriptions about the source code so that it can be understood by other programmers if they wish to use that program for future development.
C and C++ support two ways to insert comments:
// single line comment
/* multiple lines comment */
What are keywords in C?
Keywords are those words whose meaning and their functions are already known to the Compiler. Different keywords are used for different purposes. There are 32 keywords in C.
Eg: int, long, float, double, break, continue, goto etc.
What are the different types of Conditional Statements?
Types of Conditional Statements:
1. If statement: It executes the statements if the condition within it is true.
Syntax:
if (condition)
{
Statements;
}
2. If else statement: If else statement executes the statements within the if block if condition is true but if the condition is false then it executes statements that are within the else block.
Syntax:
if(condition)
{
Statements;
}
else
{
Statemments;
}
3. Else if statement: Else if statement is used to execute the statements by checking multiple conditions. If any one condition out of the multiple conditions is true then statements within that block executes. If no condition is true then statements in else block executes.
Syntax:
If(condition 1)
{
Statement block1;
}
else if (condition 2)
{
Statement block 2;
}
else if (condition n)
{
Statement block n;
}
else
{
Statements;
}
4. Switch statement: It is used to execute the statements by checking the multiple conditions or choices that are available. Switch statement uses multiple cases. A particular case executes if its value matches the value of switch variable.
Syntax:
Switch (variable)
{
case item1: statements 1;
Break;
case item2: statements 2;
Break;
default: statements;
}