Hot Topics
Deloitte Solution
Technical Round
- Question 1
How would you rate your Java skills?
- Answer
You can rate yourself on the basis of how comfortable with Java you are. But don’t rate yourself too high or too low and rate yourself on 5.
You can say 3.5 out of 5.
- Question 2
What are the four pillars of Java?
- Answer
The 4 pillars of JAVA are:
Inheritance: It is a concept of Object Oriented Programming in which a new class is created from the existing one.
Polymorphism: Poly means many and morph means form. A concept that enables programmers to assign a different meaning or usage to a variable, function or an object in different context.
Polymorphism can be of two types:
Runtime Polymorphism
Compile Time Polymorphism
Abstraction: Creating a new data type using encapsulated items that is well suited for an application.
Encapsulation: It is called data hiding and encapsulation is the way of packing data and function into a single unit to hide the implementation details of a class from outer world.
- Question 3
Suppose I am a student who has no idea of coding. How would you explain the concept of inheritance to me?
- Answer
Inheritance is a concept by which a child gets access to the parent properties. For example you will get wealth of your parents but you won’t get wealth from someone else’s parent.
- Question 4
What is multi-threading in Java?
- Answer
Multi-threading in Java refers to the execution of more than one thread simultaneously for maximum utilization of CPU.
- Question 5
Given an array and n value. How will you reverse the array up to n value?
- Answer
Here’s an example of reversing an array up to a given n
value in C:
#include<stdio.h>
void reverseArray(int arr[], int n)
{
int i, temp;
for (i = 0; i < n/2; i++)
{
temp = arr[i];
arr[i] = arr[n-i-1];
arr[n-i-1] = temp;
}
}
void printArray(int arr[], int size)
{
int i;
for (i=0; i < size; i++)
printf("%d ", arr[i]);
printf("\n");
}
int main()
{
int arr[] = {1, 2, 3, 4, 5, 6};
int n = 4;
printf("Original array: \n");
printArray(arr, n);
reverseArray(arr, n);
printf("Reversed array up to %d: \n", n);
printArray(arr, n);
return 0;
}
/*
OUTPUT -
Original array:
1 2 3 4
Reversed array up to 4:
4 3 2 1
*/
- Question 6
Write a program for maximum sum subarray.
- Answer
#include<iostream>
using namespace std;
int maxSum(int arr[],int n){
int MAX=INT_MIN;
int sum=0;
for(int i=0;i<n;i++){
sum+=arr[i];
MAX=max(sum,MAX);
if(sum<0){
sum=0;
}
}
return MAX;
}
int main() {
int n;
cout<<"Enter the length of array:"<>n;
int arr[n];
cout<<"Enter the values in the array"<<endl;
for(int i=0;i>arr[i];
}
int s=maxSum(arr,n);
cout<<"Maximum contiguous sum is: "<<s;
return 0;
}
/*
INPUT:
Enter the length of array:
8
Enter the values in the array
-2 -3 4 -1 -2 1 5 -3
OUTPUT:
Maximum contiguous sum is: 7
*/
- Question 7
What is normalization and what are its types?
- Answer
Normalization is process to analyse the given relational schemas based on their functional dependencies and primary key to minimize data redundancy and minimize insertion, deletion and update anomalies.
Types of normalization:
1NF
2NF
3NF
BCNF
4NF
5NF
- Question 8
What are ACID properties?
- Answer
ACID properties provides the mechanism to make a database consistent and to ensure integrity of data.
Atomicity: It states that either all the operations in a transaction should be reflected in the database or none should be reflected in database. E.g. If a transaction gets any obstruction during processing then it would restart itself from the very first stop.
Consistency: Before a transaction start and after a transaction is completed the sum should remain same.
Isolation: Converting parallel schedule to serial schedule to gain consistent schedule.
Durability: All changes in the database should be permanent.
- Question 9
What is a VPN?
- Answer
VPN stands for virtual private network which is used for personal or work usage. It provides a private network which makes a connection more secure while working on a public network.
- Question 10
What is virtual memory?
- Answer
Virtual memory is a technique in operating system by which secondary memory can be addressed as it was a part of main memory.
- Question 11
What is abstraction?
- Answer
Abstraction refers to the quality of dealing with ideas rather than events. It’s basically deals with hiding the details and showing the essential things to the user. Thus you can say that abstraction in Java is the process of hiding the implementation details from the user and revealing only the functionality to them. Abstraction can be achieved in two ways:
Abstract classes
Interfaces
- Question 12
What is paging?
- Answer
Paging is concept in which we divide a process in equal size of pages and put it into frames of main memory.
- Question 13
What is function overriding?
- Answer
Function overriding happens when a child class has same function as parent class.
- Question 14
You have a student names table and marks obtained table. Write a query to find the highest, second highest and so on marks.
- Answer
Oracle
SELECT name, MAX(salary) AS salary FROM employee WHERE salary <> (SELECT MAX(salary) FROM employee);
OR
Common Table Expression
WITH T AS ( SELECT * DENSE_RANK() OVER (ORDER BY Salary Desc) AS Rnk FROM Employees) SELECT Name FROM T WHERE Rnk=n;
- Question 15
Explain bubble sorting algorithm along with code.
- Answer
Here’s an example of the bubble sort algorithm in C:
#include<stdio.h>
void swap(int *xp, int *yp)
{
int temp = *xp;
*xp = *yp;
*yp = temp;
}
void bubbleSort(int arr[], int n)
{
int i, j;
for (i = 0; i < n-1; i++)
for (j = 0; j < n-i-1; j++)
if (arr[j] > arr[j+1])
swap(&arr[j], &arr[j+1]);
}
void printArray(int arr[], int size)
{
int i;
for (i=0; i < size; i++)
printf("%d ", arr[i]);
printf("\n");
}
int main()
{
int arr[] = {64, 34, 25, 12, 22, 11, 90};
int n = sizeof(arr)/sizeof(arr[0]);
bubbleSort(arr, n);
printf("Sorted array: \n");
printArray(arr, n);
return 0;
}
/*
OUTPUT -
Sorted array:
11 12 22 25 34 64 90
*/
- Question 16
What is primary key and foreign key?
- Answer
Primary key is a constraint in database that helps us to uniquely identify each record in the table and should not contain NULL values.
Foreign key is an attribute or a set of attributes that references to primary key of the same table or another table
- Question 17
What are joins in DBMS?
- Answer
Joins in DBMS can be only used when you have something/ attribute common in both the tables.
- Question 18
What is a binary search tree?
- Answer
Binary search tree is a node based tree data structure which has the following properties:
The nodes in the left subtree of the root contains elements whose value are lesser than the root element.
The nodes in the right subtree of the root contains elements whose value are greater than the root element.
- Question 19
Write a program for finding factorial of a number using recursion in C++.
- Answer
#include<iostream>
int fact(int);
int main()
{
int n=5;
printf("%d",fact(n));
return 0;
}
int fact(int n){
if(n==1){
return 1;
}
return n*fact(n-1);
}
/*
OUTPUT:
120
*/
- Question 20
Write a program to swap two variables without using a temporary variable.
- Answer
#include<stdio.h>
int main() {
int a,b;
printf("Enter the value of a: ");
scanf("%d",&a);
printf("Enter the value of b: ");
scanf("%d",&b);
a=a-b;
b=a+b;
a=b-a;
printf("After swapping the value of a is:%d\n",a);
printf("After swapping the value of b is:%d",b);
return 0;
}
/*
INPUT:
Enter the value of a: 5
Enter the value of b: 4
OUTPUT:
After swapping the value of a is:4
After swapping the value of b is:5
*/