Interrview Preparation For Languages
Interrview Preparation For Languages
What is an array ?
Araay is an data structure which store similar kind of elements into it in a
sequential order , their are mainly three types of arrays 1.one dimensional
array,2.two dimensional array,3.three dimensional array
What is the difference between call by value and the call by reference ?
-In call by reference, the memory allocation is similar for both formal parameters
and actual parameters. All the operations in the function
are performed on the value stored at the address of the actual parameters, and the
modified value gets stored at the same address.
Differentiate between declaring header files with < > and ""
-< > - compiler searches for the header file within the built -in path
" " - the compiler will searches for the header files in the current working
directory. If not found, it searches for the file in other location.
#######PROGRAMS IN C LANGUAGE
#########
int main() {
int n;
int fact=1;
cout<< "Enter a positive integer: ";
cin >> n;
if (n < 0)
{
cout << "Error";
}
else {
for(int i=1; i<=n;++i)
{
fact *= i;
}
cout << "Factorial of " << n << " = " << fact;
}
return 0;
10. What if we compile the program without the main fuction, but we cannot run or
execute the program bcoz the main() function is the entryb point
from where all the execution begins and without the entry point , the program is
not executable
int main()
{
string s;
cout <<"Enter the sentence with spaces "<<end1;
getline(cin,s)
cout<< s;
return 0;
}
26.What is inharitance ?
-Inheritance is the mechanism in which we can create a new class i.e child classs
from the existing class i.e parent class. this child class is also known
as a derived class and the parent class is also called as the base class .
**************JAVA INTERVIEW
QUESTIONS*******************
What is Java?
--> Java is the high-level programming language which is based on the principles of
object-oriented programming and can be used to develop large-scale applications.
1. what is JVM ?
-->java virtual machine is the abstract machine that provides runtime environment
to exicute the code.
6. What is an interface?
--> The interface provides a way to achieve abstraction in Java and used to define
the contract for the subclasses to implement.
12. Difference between Heap and Stack Memory in java. And how java utilizes this ?
--> Stack memory is the portion of memory that was assigned to every individual
program. And it was fixed.
Heap memory is the portion that was not allocated to the java program but it
will be available for use by the java program when it is required,
mostly during the runtime of the program.
JVM - (Java Virtual Machine) JVM is a part of JRE that executes the Java
program at the end. Actually, it is part of JRE,
but it is software that converts bytecode into machine-executable code to
execute on hardware.
26. What do you understand by the terms variables and methods of an Object?
--> variables : Values assigned to the instance variables of an object make up the
object's state.
functions/methods : Methods/functions are where the class logic is stored.
This is where the
data gets manipulated or algorithms get executed. Functions are also called
procedures or methods.
30. What is the use of the final and super keyword in java?
--> By declaring the variable as final, the value of the final variable cannot be
changed.
By declaring the method as final, method cannot be overridden.
By declaring the class as final, class cannot be extended.
The super keyword is used to access superclass (Parent class) variables and
methods by subclass objects
31. Can we stop method overriding without using the final keyword?
--> Yes, we can stop the method overriding by declaring the method as private or
static.