Looking For Anything Specific?

ads header

Technical Interview Questions with Answers - Part 2

 


Technical Interview Questions with Answers - Part 1

Here is the part 2 of the most commonly asked technical interview questions with answers.

1. & Symbol

    It is used in two different places, one as a bitwise operator and other as a pointer address of operator. Returns the address of a variable and Binary AND Operator copies a bit to the result if it exists in both operands.

2. How to write a function in C?

return_type function name(parameter)

{

body

}

3. Differentiate Array and Pointer.

Array:

  • Collection of elements of similar datatype.
  • Size of array decides number of variables to be stored.
  • They are static.
Pointers:
  • Variable that stores the address of another variable.
  • Can store address of only one variable.
  • They are dynamic.
4. How is memory allocated dynamically?
    Malloc (memory allocation) method in C is used to dynamically allocate a single large block of memory with specific size.

5. Differentiate Array and Linked List.
Array:
  • Elements are stored in contiguous memory location.
  • Memory is allocated at compile time.
  • Works with static memory.
Linked List:
  • Elements are stored randomly anywhere in the memory.
  • Memory is allocated at run time.
  • Works with dynamic memory.
6. Differentiate Array and Structure.
Array:
  • Consists of elements of same datatype.
  • Size is fixed.
  • Declaration is done using "[]" - square brackets and not any keyword.
Structure:
  • Consists elements of different datatype.
  • Size is not fixed.
  • Declaration is done using the keyword "struct".
7. Differentiate Structure and Union
Structure:
  • "struct" keyword is used to define.
  • Several members can be initialized at once.
  • Each member is assigned unique storage area of location.
Union:
  • "union" keyword is used to define.
  • Only first member can be initialized.
  • Memory is shared by each members.
8. Storage classes in C.
    Auto, extern, static and register are the storage classes in C.

9. Differentiate While and Do-While.
While:
  • Checks condition first and then executes the statement.
  • Entry controlled loop.
  • Loop does not execute if condition is false.
Do-While:
  • Executes the statement atleast once and then the condition is checked.
  • Exit controlled loop.
  • Statement is executed atleast once even if the condition is false.
10. How to declare a variable in C?
    datatype variable_name = value;

11. Variable declaration and Initialization in C;
Variable declaration:
    datatype variable_name;

Variable Initialization:
    datatype variable_name = constant;

12. Static Keyword:
    Static keyword is used in Java for memory management. Variables, data members or functions cannot be modified again if the static keyword is used.

13. Default storage class on declaring a variable:
    Auto

14. Garbage Value
    If a variable is assigned but not allocated it is known to have garbage value.

15. Exception
    It is an event which occurs during program execution which disrupts the normal flow of the program.

16. Differentiate Error and Exception:
Error:
  • It occurs at compile or run time.
  • Caused by the application.
  • Belongs to java.lang.Exception package.
Exception:
  • Occurs at run time.
  • Caused by environment in which application is running.
  • Belongs to java.lang.Error package.
17. Example for Exception
    If a number is divided by zero arithmetic exception occurs.

18. Differentiate Destructor and Constructor
Destructor:
  • Used to destroy the instances.
  • It cannot be overloaded.
  • In a class only single destructor.
Constructor:
  • Used to initialize the object of the class.
  • It can be overloaded.
  • There can be multiple constructors in a class.
19. How to allocate memory in constructor?
    Constructors can be used to initialize member objects and to allocate memory. Memory allocation at runtime is known as dynamic memory allocation. The new operator is used for dynamic memory allocation.

20. Why there is no destructor in Java?
    Garbage collector automatically deletes the unused objects to free up the memory hence there is no destructor in Java.

21. Order of execution of constructor
    The constructor call is from the base class to the derived class. Java will create a constructor if not defined. It is executed when instance of class is created.

22. Whenever Object is called what happens?
    Whenever an object is called memory is allocated.

23. Condition / Ternary Operator
    It is similar to the if-else statement.
    Syntax:
        variable = exp1 ? exp2 : exp3

24. If- else statement
    It is used to check a condition and perform operation.
    Syntax:
        If(condition)
            {
             }

25. Syntax of array, struct, pointer and function.
Array:
    datatype array_name[array size];
Struct:
    struct structure_name {
        datatype member 1;
        datatype member n;
    };
Pointer:
    datatype*pointer_name;
Function:
    return_type function_name(parameter) {
    }

26. Joins in SQL
    

  • INNER JOIN - Returns records that have matching values in both tables.
  • LEFT (OUTER) JOIN - Returns all records from the left table and matched records from right table.
  • RIGHT (OUTER) JOIN -Returns all records from the right table and matched records from left table.
  • FULL (OUTER) JOIN -Returns all records which match in either left or right table.
27. Differentiate Inner and Outer Join
Inner Join
  • Join and Inner Join are same.
  • Combined tuple between two or more tables.
Outer Join
  • Full outer join and outer join are same.
  • Returns combined tuple from specified table.
28. Differentiate Left and Right Join
Left Join
  • Returns all from left table and matching from right table.
  • Also known as left outer join.
  • Contains null value if no matching row on right table.
Right Join
  • Returns all from right table and matching from left table.
  • Also known as right outer join.
  • Contains null value if no matching row on left table.
29. Full Outer Join:
    Returns all the records from the table when there is match in the left and right table. It is also known as Full Join. It can return large results.

30. Commit, Rollback, Save point
Commit:
    It is a transaction control language used to save changes done in transactions in the table.
Rollback:
    It is used to undo transactions that are not saved in database.
Save Point:
    It is used with rollback command. It is used to mark transaction in the table.

31. Like Operator
    It is used in WHERE to search specifically from the table. % and _ symbol are used to search using like operator.

32. OOPS concepts
class:
    Blueprint of how object should be represented. It is also a collection of variables and methods.
Object:
    Instance of class is called object. State and behaviour are its two properties.
Method:
    It is used to perform a specific task.
Abstraction:
    Gathering of essential details and hiding real implementation(background details.).
Encapsulation:
    Binding of variables and methods in class with access rights(security).
Inheritance:
    Process of deriving a sub class from super class. One class inherits the feature of other class.
Polymorphism:
    Ability of doing same thing for different purposes.

33. Increment Operator
    Increases the value of variable by 1.
  • If you use the ++ operator as a prefix, the value of variable is incremented by 1 and then it returns the value.
  • If you use the ++ operator as a postfix, the original value of variable is returned first and then variable is incremented by 1.
34. RDBMS
    Relational database management system is a database management system based on relational model. All modern DBMS are based on RDBMS.

35. DBMS
    It is a software used to manage the database.

36. What is Python?
    It is an interpreted, object oriented, high level programming language with dynamic semantics.

37. What is Interpreted Language?
    Programming language which are interpreted without compiling the program to machine instructions.

38. Looping Structures
While:
    while(condition){
        statements;
        }
Do-while:
    Condition is executed after the body.
For Loop:
    for(init_value; condition; increement)
        {
            statements;
            }
Break Statement:
    Used to stop a loop. Used mostly with switch statement.
Continue Statement:
    Stay in the loop and skip to next iteration.

39. Why do we use array?
    When many variables of same datatype are needed array is used.

40. Python - List, Tuple, Access Specifier
List:
    Store multiple items in single variable. They are created using square brackets.
Tuple:
    It is ordered and unchangeable. They are created using round brackets. They store multiple items in single variable.
Access specifier:
    public, protected, private.

41. HTML tags

42. C key features
  • Simple
  • Portable
  • Structured
  • Recursion
  • Pointers
  • Memory management
  • Rich Library, etc.
43. Differentiate Data Encapsulation and Abstraction.
Data Abstraction:
  • Hide data in single entity to protect information from outside.
  • Implemented using access modifier.
Data Encapsulation:
  • Hide unwanted information.
  • Implemented using abstract class and interfaces.
44. SQL Trigger
    It is a stored procedure in database which automatically invokes whenever a special event occurs in the database.

45. Dynamic memory allocation
    Procedure where size of data structure is changed during runtime. malloc, calloc, free and realloc are the different functions.

46. Concatenate
    It is the operation of joining two strings together.

47.Write Sql query to print employee name which starts with 'a' from employee table.
    SELECT * FROM EMPLOYEE_TABLE WHERE NAME LIKE 'a%';

48. Write SQL query to print MIN and MAX salary from employee table.
    SELECT MAX(salary), MIN(salary) FROM EMPLOYEE_TABLE

49. SQL query to Create a Table
    CREATE TABLE table_name (
    column1 datatype,
    column2 datatype,...
    column n datatype,
);

Post a Comment

0 Comments