Sunteți pe pagina 1din 4

Interview Questions

Q1- Tell something about yourself?


Q2- Explain the syntax for for loop.
Ans-for(expression-1;expression-2;expression-3) {}

Q3-What is a static variable?


Ans-A static local variables retains its value between the function call and the default
value is 0. The following function will print 1 2 3 if called thrice.

Q4- What is a dangling pointer?


Ans-A pointer initially holding valid address, but later the held address is released or
freed. Then such a pointer is called as dangling pointer.

Q5-What is a preprocessor?
Ans-Preprocessor is a directive to the compiler to perform certain things before the
actual compilation process begins.

Q6-Describe the file opening mode “w+”.


Ans-Opens a file both for reading and writing. If a file is not existing it creates one,
else if the file is existing it will be over written.

Q7- Define an array.


Ans-Array is collection of similar data items under a common name.

Q8-What is variable.
Ans-A variable is the name storage.

Q9-Why prototype of function used?


Ans-Prototype of a function can be used to declare a function

Q10-Properties of Oops?
Ans-1.Polymorphism 2.Encapsulation 3.Inheritence 4.Abstraction.

Q11-What is the Return Type of void?


Ans- Null

Q12-How will you print “Hello World” without semicolon?


Ans- #include <stdio.h>
int main(void)
{
if (printf("Hello World")) { }
}
Q13- What is stdio in c?
Ans-It is a header file which defined the function printf() and scanf().

Q14- Memory size of char,int,float,double?


Ans- 1 Byte,2 Byte, 4 Byte, 8 Byte.

Q15- What is the difference between ++a and a++?

Ans) ‘++a” is called prefixed increment and the increment will happen first on a
variable. ‘a++' is called postfix increment and the increment happens after the value
of a variable used for the operations.

Q-16 Can one function call another?


ans- Yes, any user defined function can call any function.

Q-17 Why pointers are not used in Java?


ans- Java doesn’t use pointers because they are unsafe and increases the complexity
of the program. Since, Java is known for its simplicity of code, adding the concept of
pointers will be contradicting. Moreover, since JVM is responsible for implicit
memory allocation, thus in order to avoid direct access to memory by the user,
pointers are discouraged in Java.

Q-18 What is final keyword in Java?


ans- final is a special keyword in Java that is used as a non-access modifier.

Q19- can multiple inheritence supported in Java and C#?


Ans- No, It can be achieved by interface.

Q20- What is a class?


Ans-A class is a blueprint from which objects are created. A class contains methods
and variables associated with an instance of a class.

Q21-What is an object?
Ans-An object is an instance of a class .

Q22-What is a constructor?
Ans-A constructor is methods which are used to create an Object of class. There are
two types of constructor Default & Parameterized constructor

Q23-What is inheritance?
Ans-Inheritance is property in which the property of a parent class(Superclass) is
passed on to child class(Subclass).

Q24-What is polymorphism?
Ans-Polymorphism is the ability of an object to take on multiple forms. Most
commonly polymorphism is used in OOP when a parent class reference is used to
refer to a child class object.

Q25-What is a singleton class?


Ans-Singleton class limits the number of objects created for a class to one but gives
the flexibility of creating more objects if the situation changes.

Q26-What is the different type of access modifiers?


Ans-There are four type of access modifiers as given below:-
• Visible to the overall package. No modifier needed.
• Private – Visible to class only.
• Public – Visible to the world.
• Protected – Visible to package and subclass.

Q27-Difference between overloading and overriding?


Ans-Overloading is when two or more methods in the same class have the same
method name but different parameters(i.e different method signatures).
Overriding is when two methods having the same method name and parameters (i.e.,
method signature) but one of the methods is in the parent class and the other is in the
child class.

Q28-What is an Interface?
Ans-The interface is a reference type in Java, similar to the class but its collection of
abstract methods. A class can implement multiple interfaces.

Q29-What is an abstract class?


Ans-A class which contains the abstract keyword in a declaration is called abstract
class. The properties of the abstract class are as follows:-
• Abstract classes may or may not contain abstract methods but, if a class has at
least one abstract method, then it must be declared abstract.
• The abstract class cannot be instantiated.
• To use an abstract class, we have to inherit it from another class.
• If we inherit an abstract class, then we have to provide implementations to all
the abstract methods in it.

Q30- Can multiple catch blocks be executed?


Ans-No, Multiple catch blocks can't be executed. Once the proper catch code
executed, the control is transferred to the finally block and then the code that follows
the finally block gets executed.

Q31- What is the difference between public, static and void?


Ans-Public declared variables or methods are accessible anywhere in the application.
Static declared variables or methods are globally accessible without creating an
instance of the class. Static member are by default not globally accessible it depends
upon the type of access modified used. The compiler stores the address of the method
as the entry point and uses this information to begin execution before any objects are
created. And Void is a type modifier that states that the method or variable does not
return any value.

Q32-Can a private virtual method be overridden?


Ans-No, because they are not accessible outside the class.

Q33-Write down the C# syntax to catch exception?


AnsTo catch an exception, we use try catch blocks. Catch block can have parameter
of system.Exception type.
Eg:
try {
GetAllData();
}
catch (Exception ex) {
}

SQL Questions:

1. Write a SQL query to fetch the count of employees working in project 'P1'.
Ans-SELECT COUNT(*) FROM EmployeeSalary WHERE Project = 'P1';

2.Write a SQL query to fetch employee names having salary greater than or equal to
5000 and less than or equal 10000.
Ans-SELECT FullName
FROM EmployeeDetails
WHERE EmpId IN
(SELECT EmpId FROM EmpolyeeSalary
WHERE Salary BETWEEN 5000 AND 10000);

S-ar putea să vă placă și