What are the different data types available in C or C++?

Data types are used to specify the type of values to be stored in the variables.
1. Int: Integer (int) data type is used to store the whole numbers i.e. numbers without decimal points. It takes two bytes of memory.
2. Char: Char data type is used to store only characters. A character may be a number, alphabet or any symbol. It takes one byte of memory to store one variable.
3. Long: This data type is also used for storing whole numbers but of higher range than that of int. It takes four bytes of memory.
4. Float: This data type is used to store real numbers and it takes four bytes of memory.
5. Double: It is another data type to store real numbers but of higher range than the float.

What is type casting?

Type casting is used to convert the data type from lower data type to higher data type and vice versa in order to perform operations with different data types in an expression.

Syntax:
Type variable1= (type)variable2;

Types of casting:
1. Implicit typecasting: Implicit typecasting is that typecasting which occurs automatically by the compiler when data type is converted into the higher type from lower.
Eg: short x=500;
Int y;
y=x;

2. Explicit typecasting: Explicit typecasting means that typecasting which does not occur automatically rather when they occur when programmer himself wants to convert a higher data type to lower type or vice-versa.
Eg: short x=500;
int y;
y = (int) x;

What are the different String functions available?

String Functions available in C:
1. Strlen (): strlen is used to find out the length of the string i.e. how many characters are there in string.
Syntax :strlen (str)

2. Strcpy (): strcpy() is used to copy one string to other string.
Syntax: Strcpy (str1, str);

3. Strcat (): strcat() is used to add one string at the end of another string. In other words it is used to join two strings.
Syntax: strcat (str, str1);

4. Strcmp(): strcmp() is used to make comparison between two strings. It returns 0 if both the strings are equal. Returns negative number if first string is less than second string. Returns positive number if first string is greater than second string
Syntax: strcmp(str,str1)

5. strlwr (): strlwr() is used to convert the whole string into lower characters.
Syntax: strlwr(str);

6. strupr ():strupr () is used to convert the whole string into upper characters.
Syntax: strupr(str)

7. Strrev(): strrev() is used to reverse the string.
Syntax: strrev(str)

What are Loop statements or Iteration Statements?

Loop statements are used to execute certain set of statements again and again in a program.
Different types of Loops:
1. While loop: While loop is used to execute the statements within it till the condition is true.
Syntax:
while(condition)
{
Statements;
}
2. Do while loop: Do while loop is also used to execute the statements till the condition is true but in this loop, statements will be executed first after that the condition will be checked. It will execute the statements at least one time even if the condition is false at the beginning.
Syntax:
do
{
statements;
}
While (condition);
3. For loop : In For loop, all the three parts of the loop that is initialization, condition and iteration are all written in a single statement. Initialization means initial value given to variable, condition upto which loop will execute and iteration is increment or decrement of value of variable.
Syntax:
For(initialization; condition; iteration)
{
Statements;
}

What is a header file?

Header files are used to store the inbuilt functions that are available in C or C++. If we want to use those inbuilt functions in our program we have to include that particular header file at the beginning of the program. For performing mathematical functions like square root (sqrt), sin, cos etc. we have to include the header file math.h.
Eg: printf (), scanf () are stored in header file stdio.h

What is a Union?

Union is quite similar to structure. Like structure, union is also used to store data of different data types. The only difference between structure and union is that in case of structure different variables are stored in their individual space in memory where as in case of Union total space that is required by the variables in memory is equal to the size of largest data type.
Eg: union student
{
int roll;
char name[10];
float marks;
}
The union student will take 10 bytes in memory that is equal to the size of largest variable.

What are the Java tokens?

Java tokens mean the smallest individual units in a program. It includes five types of tokens:
1. Keywords.
2. Identifiers
3. Literals
4. Operators
5. Separators
1. Keywords: The words which are reserved in a language for specific purposes are known as Keywords. These keywords are written in lower-case (small letters). Their meaning and their functions are already known to the compiler. Java has 50 keywords. Since different keywords are used for different purposes they cannot be used as an identifier for variables, classes, methods etc.

2. Identifiers: Identifiers are the names given to the variables, classes, methods, objects, labels and interfaces in program Java identifiers follow the following rules:
1. It should not be a keyword which is available in the language.
2. First character of identifier should be an alphabet or underscore.
3. No other special character is allowed except underscore (_).
4. Both the cases that are upper case and lower case are allowed. An identifier student is not same as STUDENT.

3. Literals (Constants): Literals are used to store constant values (that cannot be changed) in variables. They are a group of characters which can be letters, digits etc. There are five types of literals in Java. They are:
1. Integer literals
2. Floating point literals
3. Character literals
4. String literals
5. Boolean literals.

4. Operators: Operator specifies which operation to be performed on the variables in an expression. Different operators perform different kinds of operations.
1. Arithmetic operators
2. Relational operators
3. Logical operators
4. Assignment operators
5. Increment and decrement operators
6. Conditional operators
7. Bitwise operators
Special operators like instance of and dot operator (.)

5. Separators: Separators are basically used to define the structure of the source code.
E.g. parentheses () – used for sending and receiving arguments in a function.
braces { } – used for assigning values to array at the time of its declaration and also used for block of statements.
Brackets [ ] – used for declaring array and accessing its elements
Semi color; – used at the end of every line

What are the native methods in Java?

Native methods are the methods whose source code is written in any other languages like C, C++ etc. Native methods are used when that it very difficult to rewrite the already existing code of other programming languages like C, C++ etc in Java. In order to declare a native method native keyword is used like public native method_abc(). This native keyword is used for informing the java compiler that this method has been written in a language other than java.

What is Thread Synchronization?

Thread synchronization is the process in which only one thread can use a particular method or object and no other thread can access the same method or object at the same time. Thread gets a lock on the object and until the thread releases the lock from that object no other thread can use the same object.

“Synchronized” keyword is used in Java to implement thread synchronization.
Synchronized keyword can be used in two ways:
1. Synchronized keyword can be used with the methods. When a method is declared synchronized then the thread gets a lock on that method and unless that thread releases the lock no other thread can use that method.
For e.g.: synchronized void deposit()
{

}

2. Synchronized keyword can also be used with a block of statements. We can apply synchronized to a set of statements rather than the whole methods.
Eg: synchronized (object)
{

}

What are the different keywords in JAVA?

The meaning and the functions of keywords are already known to the compiler of the language. These are the reserved words. Different keywords are used for different purposes.
E.g.: Boolean, byte, try, catch, class, extends, final, finally, implements, import, instance of, int, interface, new, package, private, protected, public, super, synchronized, throw, throws etc.