0% found this document useful (0 votes)
11 views59 pages

TR Questions Infosys3

The document covers various technical topics including client-server architecture, network protocols, Java and C++ programming concepts, object-oriented programming principles, data structures, databases, and algorithms. It provides definitions, comparisons, and explanations of key concepts such as inheritance, polymorphism, and different data types. Additionally, it discusses the differences between various programming constructs and data handling methods.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views59 pages

TR Questions Infosys3

The document covers various technical topics including client-server architecture, network protocols, Java and C++ programming concepts, object-oriented programming principles, data structures, databases, and algorithms. It provides definitions, comparisons, and explanations of key concepts such as inheritance, polymorphism, and different data types. Additionally, it discusses the differences between various programming constructs and data handling methods.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 59

Top Intro HR project

Client Server Architecture?


Network Protocol

Java
1. Super keyword?
2. Object class in Java?
3. Errors and Exceptions?
4. Treemap?
5. Thread in Java?
6. Platform independence?
7. Call by Value vs. Call by Reference
8. D/B String and StringBuilder?
9. D/B ArrayList and LinkedList?

C++
1. Namespace std?
2. Diamond problem?
3. How we can Implement an interface in c++?
4. D/B Pointer and Reference variable ?
5. D/B Array and Vector?
6. D/B map and unordered_map?
OOPs –

1. Object-Oriented programming?
2. Abstraction ? Data Abstraction
3. Inheritance & types
4. Polymorphism ? (Static / Compile-Time Polymorphism)
(Dynamic / Runtime Polymorphism)
5. Encapsulation
6. Constructor & types ?
7. Static Blocks
8. Function overolading
9. Interface, use ?
10. D/B Overloading & Overriding
11. D/B Class & Object
12. D/B Abstraction and interface

Data Structure-
1. Data Structure
2. Stack & Queue
3. Stack & Array
4. Which sorting algorithm is best?
5. Hash map & hash set
6. Merge Sort.
7. Heap Sort
Database-
1. Database
2. Normalization
3. Key in DBMS Types of keys
4. D/B Primary key and unique key
5. Join in SQL
6. Referential integrity
7. Sub query
8. Acid Proporties
9. SQL Commands
10. SQL?
11. BCNF?
12. Find duplicate row or column in database
13. Primary key and the Foreign key?
14. Data manipulation languages DML ?
15. D/B Delete and truncate.
16. D/B Char and Varchar in DBMS
17. D/B Inner join and Outer join?
18. D/B DROP and DELETE command.
19. D/B MySQL & NoSQL.

Coding and Algorithm


1. Why insertion sort is adaptive?
2. Backtracking?
3. D/B Dynamic Programming and Greedy algorithm?
4. D/B Macro and ordinary definition.
5. Reverse a LinkedList.
6. Find if the cycle is present in LinkedList.
7. Sort array based on the frequency
8. Sort an array by characters.
9. find its first non-repeating character
10. Find Kth smallest element in an array.
11. While finding the shortest path in a graph which
Algorithm is used BFS or DFS?
Client server Architecture

client-server architecture, architecture of a computer network in


which many clients (remote processors) request and receive
service from a centralized server (host computer). Client
computers provide an interface to allow a computer user to
request services of the server and to display the results the
server returns. Servers wait for requests to arrive from clients and
then respond to them. Ideally, a server provides a standardized
transparent interface to clients so that clients need not be aware
of the specifics of the system (i.e., the hardware and software)
that is providing the service. Clients are often situated at
workstations or on personal computers, while servers are located
elsewhere on the network, usually on more powerful machines.
This computing model is especially effective when clients and the
server each have distinct tasks that they routinely perform. In
hospital data processing, for example, a client computer can be
running an application program for entering patient information
while the server computer is running another program that
manages the database in which the information is permanently
stored. Many clients can access the server’s information
simultaneously, and, at the same time, a client computer can
perform other tasks, such as sending e-mail. Because both client
and server computers are considered independent devices, the
client-server model is completely different from the old mainframe
model, in which a centralized mainframe computer performed all
the tasks for its associated “dumb” terminals, which merely
communicated with the central mainframe.

JAVA C OOP DS DBMS Coding & A

TOP

Network protocol

A network protocol is an established set of rules that determine


how data is transmitted between different devices in the same
network. Essentially, it allows connected devices to
communicate with each other, regardless of any differences in
their internal processes, structure or design.

1. Transmission Control Protocol (TCP)


2. Internet Protocol (IP)
3. File Transfer Protocol (FTP)
4. Hyper Text Transfer Protocol (HTTP)
5. Hyper Text Transfer Protocol Secure (HTTPS)
Transmission Control Protocol (TCP): TCP is a popular
communication protocol which is used for communicating over a
network. It divides any message into series of packets that are sent
from source to destination and there it gets reassembled at the
destination.

Internet Protocol (IP): IP is designed explicitly as addressing


protocol. It is mostly used with TCP. The IP addresses in packets
help in routing them through different nodes in a network until it
reaches the destination system. TCP/IP is the most popular
protocol connecting the networks.

File Transfer Protocol (FTP): FTP allows users to transfer files


from one machine to another. Types of files may include program
files, multimedia files, text files, and documents, etc.

Hyper Text Transfer Protocol (HTTP): HTTP is designed for


transferring a hypertext among two or more systems. HTML tags
are used for creating links. These links may be in any form like text
or images. HTTP is designed on Client-server principles which
allow a client system for establishing a connection with the server
machine for making a request.
Hyper Text Transfer Protocol Secure (HTTPS): HTTPS
is abbreviated as Hyper Text Transfer Protocol Secure is
a standard protocol to secure the communication among
two computers one using the browser and other fetching
data from web server. HTTP is used for transferring data
between the client browser (request) and the web server
(response) in the hypertext format, same in case of
HTTPS except that the transferring of data is done in an
encrypted format. So it can be said that https thwart
hackers from interpretation or modification of data
throughout the transfer of packets.

JAVA C OOP DS DBMS Coding & A

TOP
D/B Call byvalue and call by reference

Call By Reference
Call By Value

While calling a function, instead of


While calling a function,
passing the values of variables,
we pass values of
we pass address of
variables to it. Such
variables(location of variables) to
functions are known as
the function known as “Call By
“Call By Values”.
References.

In this method, the value of


In this method, the address of
each variable in calling
actual variables in the calling
function is copied into
function are copied into the
corresponding dummy
dummy variables of the called
variables of the called
function.
function.

1. Super keyword?
super can be used to refer immediate parent class instance
variable.can be used to invoke immediate parent class method.
can be used to invoke immediate parent class constructor.
2. Object Class In Java
The Object class is the parent class of all the classes in java
by default. In other words, it is the topmost class of java.
The Object class is beneficial if you want to refer any object
whose type you don't know. Notice that parent class reference
variable can refer the child class object, know as upcasting.

3. Errors and Exceptions

Error Exceptions
Errors are usually raised by Exceptions are caused by the
the environment in which the code of the application itself.
application is running. For
example, an error will occur
due to a lack of system
resources.
It is not possible to recover The use of try-catch blocks
from an error. can handle exceptions and
recover the application from
them.
Errors occur at run-time and Exceptions can be “checked”
are not known by the or “unchecked,” meaning they
compiler; hence, they are may or may not be caught by
classified as “unchecked.” the compiler.

JAVA C OOP DS DBMS Coding & A

TOP
4.Treemap?
The TreeMap in Java is used to implement Map interface
and NavigableMap along with the AbstractMap Class. The
map is sorted according to the natural ordering of its keys, or by
a Comparator provided at map creation time, depending on
which constructor is used.

5.Threads in java
A Thread is a very light-weighted process, or we can say the
smallest part of the process that allows a program to operate
more efficiently by running multiple tasks simultaneously.

Platform Indepemndence
The meaning of platform-independent is that the java
compiled code(byte code) can run on all operating
systems. A program is written in a language that is a
human-readable language. It may contain words, phrases, etc
which the machine does not understand.

JAVA C OOP DS DBMS Coding & A

TOP
6. D/B String buffer and StringBuilder

StringBuffer StringBuilder

StringBuffer is synchronized StringBuilder is non-synchronized i.e.


i.e. thread safe. It means not thread safe. It means two threads
two threads can't call the can call the methods of StringBuilder
methods of StringBuffer simultaneously.
simultaneously.
StringBuffer is less efficient StringBuilder is more efficient than
than StringBuilder. StringBuffer.
StringBuffer was introduced StringBuilder was introduced in Java
in Java 1.0 1.5

7. D/B Array list And Linked List

ArrayList LinkedList

1) ArrayList internally uses a LinkedList internally uses a doubly


dynamic array to store the linked list to store the elements.
elements.
2) Manipulation with ArrayList is Manipulation with LinkedList is
slow because it internally uses an faster than ArrayList because it
array. If any element is removed uses a doubly linked list, so no bit
from the array, all the other shifting is required in memory.
elements are shifted in memory.
3) ArrayList is better for storing LinkedList is better for
and accessing data. manipulating data.
4) To be precise, an ArrayList is a LinkedList implements the doubly
resizable array. linked list of the list interface.
JAVA C OOP DS DBMS Coding & A

TOP

Call by Value vs. Call by Reference

Call BY Value Call by Reference


While calling a function, when you While calling a function, in
pass values by copying variables, programming language instead of
it is known as “Call By Values.” copying the values of variables,
the address of the variables is
used it is known as “Call By
References.
In this method, a copy of the In this method, a variable itself is
variable is passed. passed.
Original value not modified. The original value is modified.
Actual and formal arguments Actual and formal arguments
will be created in different will be created in the same
memory location memory location
Default in many programming It is supported by most
languages like C++.PHP. Visual programming languages like
Basic NET, and C#. JAVA, but
not as default.

JAVA C OOP DS DBMS Coding & A

TOP
1.Namespace std
In C++, a namespace is a collection of related names or
identifiers (functions, class, variables) which helps to separate
these identifiers from similar identifiers in other namespaces or
the global namespace. The identifiers of the C++ standard
library are defined in a namespace called std .

2. Diamond Problem in C++

The Diamond Problem occurs when a child class inherits from


two parent classes who both share a common grandparent
class.

3. How we can Implement an interface in c++?


C++ has no built-in concepts of interfaces. You can implement it
using abstract classes which contains only pure virtual
functions. Since it allows multiple inheritance, you can inherit
this class to create another class which will then contain this
interface (I mean, object interface :) )

JAVA C OOP DS DBMS Coding & A

TOP
4. D/B Pointer and Reference variable ?
● References are used to refer an existing variable in
another name whereas pointers are used to store address
of variable.
● References cannot have a null value assigned but pointer
can.
● A reference variable can be referenced by pass by value
whereas a pointer can be referenced by pass by reference.
● A reference must be initialized on declaration while it is not
necessary in case of pointer.

5. D/B Array and Vector?

● A Vector is a sequential-based container whereas an array is a


data structure that stores a fixed number of elements
(elements should of the same type) in sequential order.
Vectors are sometimes also known as dynamic arrays.
● Arrays can be implemented in a static or dynamic way
whereas vectors can only be implemented dynamically.
● Arrays have a fixed size whereas vectors have a dynamic size
i.e they can resize themselves. Whenever you add or remove
elements from the vector, the size automatically changes.

JAVA C OOP DS DBMS Coding & A

TOP
6. D/B Map And unordered_map

Map Unordered_map
map is define in #include <map> unordered_map is defined in
header file #include <unordered_map>
header file
It is implemented by red-black It is implemented using hash
tree. table.
It is slow. It is fast.
Time complexity for operations is Time complexity for operations is
O(log N) O(1)

JAVA C OOP DS DBMS Coding & A

TOP
1.What is Object-Oriented programming?

OOP stands for object oriented programming. Object-oriented


programming is a core of Java Programming, which is used for
designing a program using classes and objects. Object-oriented
programming aims to implement real-world entities like
inheritance, hiding, polymorphism etc. in programming.
OOPs Concepts -
Objects Classes Abstraction Inheritance Polymorphism
Encapsulation

Object - An object is a physical entity which has a state and


behaviour . Its occurs space in memory. It is sample of a class.
Object help to access the method and variable in the program.

Ex - (Dog) → State → Breed / Age / Color Behaviour → Bark


/ Sleep / Eat

Classes - A class is a collection of object. A class is a logical


entity which does not take any space. A class include all the
data and method which showa the behaviour of an object.

Abstraction - Abstraction is a process which displays only


the information needed and hides the unnecessary information.
We can say that the main purpose of abstraction is data hiding.

JAVA C OOP DS DBMS Coding & A

TOP
Inheritance - When one object acquires all the properties
and behaviours odf a parent object it is know as inheritance. It
provide code reusability. It is used to achieve runtime
polymorphoism.

Types of Inheritance -

In this inheritance, a derived class is created


Single inheritance -
from a single base class.

Multi-level inheritance - In
this inheritance, a derived class is
created from another derived class.

Hierarchical Inheritance - In this inheritance, more than one


derived class is created from a single base class and further
child classes act as parent classes for more than one child
class.

Hybrid inheritance This is a combination of more than one


inheritance. Hence, it may be a combination of Multilevel and
Hierarchical inheritances.

JAVA C OOP DS DBMS Coding & A

TOP
Polymorphism - Polymorphism is a method of performing “
a single task in different ways”. Polymorphism enable a
programmer to use method or operator in different way. In java
we use method overloading and overriding to obtain
polymorphism.

Types of polymorphism -

Static / Compile-Time Polymorphism - Compile-Time


polymorphism in java is also known as Static Polymorphism. to
resolved at compile-time which is achieved through Method
Overloading.

Dynamic / Runtime Polymorphism - Runtime polymorphism


in java is also known as Dynamic Binding which is used to call
to an overridden method that is resolved dynamically at runtime
rather than at compile-time.

Encapsulation - In encapsulation Binding or Wrapping code


and data together into a single unit are known as
encapsulation. A java class is a example of encapsulation.

For ex - A capsule , it is wrapped with different medicine.

JAVA C OOP DS DBMS Coding & A

TOP
D/B Class & Object
Class Object
A class is a logical entity. An object is a physical entity.
It is conceptual It is real
It binds data & method It is just like a variable of class
together into a single unit
It does not occupy space in Its occupy space in memory
memory
It is a data type that represent It is an instance of the class
the blueprint of an object
It use the keyword class when It uses the new keyword to
declared create an object
A class can exist without any Object cannot exist without a
object class

JAVA C OOP DS DBMS Coding & A

TOP
D/B Abstract Class & Interface

Abstract class Interface


Abstract class can have Interface can have only
abstract and non-abstract abstract methods. Since Java
methods. 8, it can have default and
static methods also.
Abstract class doesn't support Interface supports multiple
multiple inheritance. inheritance.
Abstract class can have final, Interface has only static and
non-final, static and non-static final variables.
variables.
Abstract class can provide the Interface can't provide the
implementation of interface. implementation of abstract
class.
The abstract keyword is used The interface keyword is used
to declare abstract class. to declare interface.
An abstract class can be An interface can be
extended using keyword implemented using keyword
"extends". "implements".

JAVA C OOP DS DBMS Coding & A

TOP
D/B overloading & Overriding

Overloading Overriding
The process of calling two The process of calling two
method having same name method one in the subclass
with different parameters is and other in the superclass
called overloading having same signature is
called overriding
It is used to increase the Provides a specific
readability of the program implementation of the method
already in the parent class
It is performed within the It involves multiple classes
same class
Parameters must be different Parameters must be same in
in case of overloading case of overriding
Is an example of compile-time It is an example of runtime
polymorphism polymorphism
Static methods can be Overriding does not involve
overloaded static methods.

JAVA C OOP DS DBMS Coding & A

TOP
Constructor & types

Constructor are special method when name is the same as tha


class name. It is a special type of method that is used to initilize
an object clas. It is created an instance of a class.

Types -

Defaulter Constructor - The DC is the constructor which


doesnt take any argument. It has no parameters.

Parametrized constructor - the constructor that take some


argument are know as parametrized constructor

Copy Constructor - A Copy Constructor is a member function


that initilizes an object using another object of the same class.

JAVA C OOP DS DBMS Coding & A

TOP
Data Abstraction - Data Abstraction is a process of hiding
unwanted or irrelevant details from the end user. It provides a
different view and help in achieving data independence which is
used to enhance the securities of data.

Static Block -

A static block is a set of instructions that is run only once when


a class is loaded into memory. A static block is also called a
static initialization block. This is because it is an option for
initializing or setting up the class at run-time.

Function Overloading -

Function Overloading in Java occurs when there are functions


having the same name but have different numbers of
parameters passed to it, which can be different in data like int,
double, float and used to return different values are computed
inside the respective overloaded method.
Interface & use -

An interface in Java is a blueprint of a class. It has static


constants and abstract methods. The interface in Java is
a mechanism to achieve abstraction . There can be only
abstract methods in the Java interface, not method body.
It is used to achieve abstraction and multiple inheritance
in Java Use - It is used to achieve abstraction. By interface, we
can support the functionality of multiple inheritance. It can be used
to achieve loose coupling.

Data structure - A data structure is a storage that is used to


store and organize data. It is a way of arranging data on a
computer so that it can be accessed and updated efficiently.

JAVA C OOP DS DBMS Coding & A

TOP
D/b Stack And Queue -

Stack Queue

The stack is based on The queue is based on


LIFO(Last In First Out) FIFO(First In First Out)
principle principle.
In S. Insertion Operation is In Q. Insertion Operation is
called Push Operation called Enqueue Operation
In S. Deletion Operation is In Q. Deletion Operation is
called Pop Operation called Dequeue Operation
Push and Pop Operation Enqueue and Dequeue
takes place from one end of Operation takes place from a
the stack different end of the queue

Simple Implementation Complex implementation in


comparison to stack
Only one pointer is used for Two pointers are used to
performing operations perform operations
Example - Example -
The stack of trays in a A queue of people at
cafeteria; ticket-window
A stack of plates in a Vehicles on toll-tax bridge
cupboard;

JAVA C OOP DS DBMS Coding & A

TOP
D/b Stack And Array -

Stack Array

A stack is a type of linear An array is a collection of data


data structure that is values that are associated to
represented by a collection one another and termed
of pieces that are arranged elements. Each element is
in a predetermined recognized by an indexed array.
sequence.
Push, pop, and peek are the t has a wide range of
operations that one can techniques or operations that
perform on a stack. can be applied to it, such as
sorting, traversing, going
backward, push, pop, etc
The size of a stack is The size of an array is fixed
dynamic.
Stacks do not permit In arrays, arbitrary access to
arbitrary access to elements. elements is permitted.

Implement One can create a Stacks cannot be used to


stack using an array. implement an array

Elements of several data The items of an array are all of


kinds may be found in a the same data type.
stack.
Which sorting algorithm is best?
Quicksort. Quicksort is one of the most efficient sorting
algorithms, and this makes of it one of the most used as well.
The first thing to do is to select a pivot number, this number will
separate the data, on its left are the numbers smaller than it
and the greater numbers on the right
characteristics:
● From the family of Exchange Sort Algorithms
● Divide and conquer paradigm
● Worst case complexity O(n²)

JAVA C OOP DS DBMS Coding & A

TOP

D/B Hash map & Hash set

Hash Map Hash Set


HashMap is a hash table HashSet is a Set. It creates a
based implementation of Map collection that uses a hash
interface. table for storage.
HashMap implements Map, HashSet implements Set,
Cloneable, and Serializable Cloneable, Serializable,
interface es. Iterable and Collection
interfaces.
In HashMap we store a In HashSet, we store objects.
key-value pair. It maintains
the mapping of key and value.
It does not allow duplicate It does not allow duplicate
keys, but duplicate values are values
allowed.
It can contain a single null key It can contain a single null
and multiple null values. value.
HashMap internally uses HashSet internally uses a
hashing to store objects. HashMap object to store
objects.

JAVA C OOP DS DBMS Coding & A

TOP

Merge Sort -

The Merge Sort algorithm is a sorting algorithm that is based on


the Divide and Conquer paradigm. In this algorithm, the array is
initially divided into two equal halves and then they are
combined in a sorted manner. T(n) = 2T(n/2) + O(n)
Heap Sort -
Heap sort is a comparison-based sorting technique based on
Binary Heap data structure. It is similar to the selection sort
where we first find the minimum element and place the
minimum element at the beginning. Repeat the same process
for the remaining elements.

What is Database?
A database is an organized collection of data, so that it can be
easily accessed and managed. You can organize data into
tables, rows, columns, and index it to make it easier to find
relevant information.

JAVA C OOP DS DBMS Coding & A

TOP
Normalization

● Normalization is the process of organizing the data in the


database.

● Normalization is used to minimize the redundancy from a relation


or set of relations. It is also used to eliminate undesirable
characteristics like Insertion, Update, and Deletion Anomalies.

● Normalization divides the larger table into smaller and links them
using relationships.

● The normal form is used to reduce redundancy from the database


table.

Key In DBMS

A key refers to an attribute/a set of attributes that help us


identify a row (or tuple) uniquely in a table (or relation). A key is
also used when we want to establish relationships between the
different columns and tables of a relational database.

Eight types of key - Super, Primary, Candidate, Alternate,


Foreign, Compound, Composite, and Surrogate Key.

JAVA C OOP DS DBMS Coding & A


TOP
D/B Primary Key and Unique Key

Primary Key Unique Key


Unique identifier for rows of a Unique identifier for rows of a
table table when primary key is not
present
Cannot be NULL Can be NULL
Only one primary key can be Multiple Unique Keys can be
present in a table present in a table
present in a table present in a table
Selection using primary key Selection using unique key
creates clustered index creates non-clustered index

SQL Join
The SQL Joins clause is used to combine records from two or
more tables in a database. A JOIN is a means for combining
fields from two tables by using values common to each

JAVA C OOP DS DBMS Coding & A

TOP
Referential Integrity
referential integrity is made up of the combination of a primary
key and a foreign key.

The main concept of REFERENTIAL INTEGRITY is that it does


not allow to add any record in a table that contains the foreign
key unless the reference table containing a corresponding
primary key.

MySQL Subquery

A subquery in MySQL is a query, which is nested into another


SQL query and embedded with SELECT, INSERT, UPDATE or
DELETE statement along with the various operators. We can
also nest the subquery with another subquery. A subquery is
known as the inner query, and the query that contains subquery
is known as the outer query. The inner query executed first
gives the result to the outer query, and then the main/outer
query will be performed.

JAVA C OOP DS DBMS Coding & A

TOP
ACID properties

To maintain the integrity of the data, there are four properties


described in the database management system, which are
known as the ACID properties. The ACID properties are meant
for the transaction that goes through a different group of tasks,
and there we come to see the role of the ACID properties.

JAVA C OOP DS DBMS Coding & A

TOP

ACID Properties -
(1) Atomicity (2) Consistency (3) Isolation (4) Durability

1. Automicity - The term atomicity defines that the data


remains atomic. It means if any operation is performed on
the data, either it should be performed or executed
completely or should not be executed at all.
2. Consistency - The word consistency means that the value
should remain preserved always. In DBMS the integrity of
the data should be maintained, which means if a change in
the database is made, it should remain preserved always.
3. Isolation - The term 'isolation' means separation. In
DBMS, Isolation is the property of a database where no
data should affect the other one and may occur
concurrently. In short, the operation on one database
should begin when the operation on the first database gets
complete. Top
4. Durability - Durability ensures the permanency of
something. In DBMS, the term durability ensures that the
data after the successful execution of the operation
becomes permanent in the database. The durability of the
data should be so perfect that even if the system fails or
leads to a crash, the database still survives.

SQL Commands
SQL commands are instructions. It is used to communicate with
the database. It is also used to perform specific tasks,
functions, and queries of data. SQL can perform various tasks
like create a table, add data to tables, drop the table, modify the
table, set permission for users.

Types - There are five types of SQL commands:


DDL, DML, DCL, TCL, and DQL.
JAVA C OOP DS DBMS Coding & A

TOP

1.Data Definition Language (DDL)

DDL changes the structure of the table like creating a table,


deleting a table, altering a table, etc. All the command of DDL are
auto-committed that means it permanently save all the changes in
the database. Some Comands - CREATE ALTER DROP
TRUNCATE

2.Data Manipulation Language (DML)

DML commands are used to modify the database. It is responsible


for all form of changes in the database. The command of DML is
not auto-committed that means it can't permanently save all the
changes in the database. They can be rollback. Some Comands -

INSERT UPDATE DELETE

3. Data Control Language (DCL) -

DCL commands are used to grant and take back authority from
any database user. Some Comands-

GRANT REVOKE

4. Transaction Control Language (TCL) -


TCL commands can only use with DML commands like INSERT,
DELETE and UPDATE only.

COMMIT ROLLBACK SAVEPOINT

JAVA C OOP DS DBMS Coding & A

TOP

5. Data Query Language (DQl) -

DQL is used to fetch the data from the database.

SELECT

D/B DELETE and TRUNCATE -

DELETE TRUNCATE
The DELETE command is This command is used to
used to delete specified delete all the rows from a
rows(one or more). table.
It is a DML(Data Manipulation it is a DDL(Data Definition
Language) command. Language) command.
DELETE command is slower TRUNCATE command is
than TRUNCATE command. faster than the DELETE
command.
To use Delete you need To use Truncate on a table we
DELETE permission on the need at least ALTER
table. permission on the table.
The delete can be used with Truncate cannot be used with
indexed views. indexed views.

JAVA C OOP DS DBMS Coding & A

TOP
D/BChar And Varchar

CHAR Data Type VARCHAR Data Type

Its full name is CHARACTER Its full name is VARIABLE


CHARACTER

It stores values in fixed lengths VARCHAR stores values in


and are padded with space variable length along with 1-byte
characters to match the specified or 2-byte length prefix and are
length not padded with any characters

It can hold a maximum of 255 It can hold a maximum of 65,535


characters. characters.

It uses static memory allocation. It uses dynamic memory


allocation.
mysql>create table emp(name
CHAR(20)); mysql>create table emp1(name
Query OK, 0 rows affected (0.25 VARCHAR(20));
Query OK, 0 rows affected (0.21

JAVA C OOP DS DBMS Coding & A

TOP
What is SQL?
SQL is Structured Query Language, which is a computer
language for storing, manipulating and retrieving data stored in
a relational database.

Primary key and the Foreign key?

Primary Key Foreign Key


It is used to identify each record It is used to links two tables
into the database table uniquely. together. It means the foreign key
in one table refers to the primary
key of another table.
The primary key column value The foreign key column can accept
can never be NULL. a NULL value
A table can have only one A table can have more than one
primary key. foreign key.
The primary key is a unique We can store duplicate values in
attribute; therefore, it cannot the foreign key column.
stores duplicate values in
relation.
The primary key is a clustered A foreign key is not a clustered
index by default, which means it index by default. We can make
is indexed automatically. clustered indexes manually.

JAVA C OOP DS DBMS Coding & A


TOP
DML
A DML (data manipulation language) refers to a computer
programming language that allows you to add (insert), delete
(delete), and alter (update) data in a database. A DML is
typically a sublanguage of a larger database language like
SQL, with the DML containing some of the language's
operators.

D/B Inner join And Outer joins

Inner Join Outer Joins


It can be used to retrieve only t is used to retrieve all
matched records between matching records as well non
both tables matching records of the tables
It doesn't return anything It return null in the column
when match is not found. values
It is faster than outer join. It is slower than inner join
because of the larger result
set

JAVA C OOP DS DBMS Coding & A

TOP
D/B Drop And Delete Comand

DELETE DROP

DELETE Command, removes DROP Command, removes named


some or all tuples/records from a elements of schema like
relation/table relations/table, constraints or
entire schema.
DELETE is DML. DROP is DDL.
Where clause is used to add No where clause is available.
filtering.
Delete command can be Drop command can't be rollbacked
rollbacked as it works on data as it works directly on data.
buffer.
Table memory space is not free Drop command frees the memory
if all records are deleted using space.
Delete Command.

JAVA C OOP DS DBMS Coding & A

TOP
D/B MySQL & NoSQL.

MySql No SQl
SQL databases are classified as NoSQL databases are known as
Relational databases, i.e., non-relational or distributed
RDBMS. database.
SQL databases have a fixed, NoSQL databases don’t have a
pre-defined schema, which pre-defined schema, which
makes the data storage more makes them schema-less and
rigid, static, and restrictive. more flexible.
SQL follows ACID (Atomicity, NoSQL is based on CAP
Consistency, Isolation and (Consistency, Availability, and
Durability) properties for its Partition Tolerance).
operations.

BCNF

BCNF (Boyce Codd Normal Form) is the advanced version of


3NF. A table is in BCNF if every functional dependency X->Y, X
is the super key of the table. For BCNF, the table should be in
3NF, and for every FD. LHS is super key.

Find duplicate row or column in database

Using the GROUP BY clause to group all rows by the target


column(s) – i.e. the column(s) you want to check for duplicate
values on. Using the COUNT function in the HAVING clause to
check if any of the groups have more than 1 entry; those would
be the duplicate values.

JAVA C OOP DS DBMS Coding & A

TOP

Why insertion sort is adaptive?


Insertion Sort is adaptive, that means it reduces its total number of
steps if given a partially sorted list, hence it increases its efficiency. Its
space complexity is less. Insertion sort requires a single additional
memory space. Overall time complexity of Insertion sort is O(n2).

Backtracking
Backtracking is an algorithmic technique whose goal is to use brute
force to find all solutions to a problem. It entails gradually compiling a
set of all possible solutions. Because a problem will have constraints,
solutions that do not meet them will be removed.

Backtracking Algorithm
Backtrack(s)

ifs is not a solution

return false

if is a new solution

add to list of solutions

backtrack(expand s)

D/B Dynamic Programming and Greedy Method

Dynamic Programming Greedy Method

1. Dynamic Programming is 1. Greedy Method is also used to get


used to obtain the optimal the optimal solution.
solution.
2. In Dynamic Programming, we 2. In a greedy Algorithm, we make
choose at each step, but the whatever choice seems best at the
choice may depend on the moment and then solve the
solution to sub-problems. sub-problems arising after the choice
is made.
3. Less efficient as compared to 3. More efficient as compared to a
a greedy approach greedy approach
4. Example: 0/1 Knapsack 4. Example: Fractional Knapsack
5. It is guaranteed that Dynamic 5. In Greedy Method, there is no such
Programming will generate an guarantee of getting Optimal Solution.
optimal solution using Principle
of Optimality.
JAVA C OOP DS DBMS Coding & A

TOP

D/B Macro & ordinary definition


1.Macro takes parameters where as ordinary definition does not.
2. Based on the parameter values to macro it can result in different
value at run time. Ordinary defination value remains same at all
place at run time.
3. Macro can be used for conditional operations where as definition
can not.
4. Using macro one can achieve inline functionality in C ie. macro
can be a function performing simple operations. This is not possible
using definitions.

JAVA C OOP DS DBMS Coding & A

TOP
Reverse a linked list

class LinkedList {

static Node head;

static class Node {

int data;
Node next;

Node(int d)
{
data = d;
next = null;
}
}

/* Function to reverse the linked list */


Node reverse(Node node)
{
Node prev = null;
Node current = node;
Node next = null;
while (current != null) {
next = current.next;
current.next = prev;
prev = current;
current = next;
}
node = prev;
return node;
}

// prints content of double linked list


void printList(Node node)
{
while (node != null) {
System.out.print(node.data + " ");
node = node.next;
}
}

public static void main(String[] args)


{
LinkedList list = new LinkedList();
list.head = new Node(85);
list.head.next = new Node(15);
list.head.next.next = new Node(4);
list.head.next.next.next = new Node(20);

System.out.println("Given Linked list");


list.printList(head);
head = list.reverse(head);
System.out.println("");
System.out.println("Reversed linked list ");
list.printList(head);
}
}

JAVA C OOP DS DBMS Coding & A

TOP
Find if the cycle is present in LinkedList.

Solution 1: Hashing Approach:


Traverse the list one by one and keep putting the node
addresses in a Hash Table. At any point, if NULL is reached
then return false, and if the next of the current nodes points to
any of the previously stored nodes in Hash then return true.

import java.util.*;
public class LinkedList {
static Node head; // head of list
static class Node {
int data;
Node next;
Node(int d)
{
data = d;
next = null;
}
}
static public void push(int new_data)
{
Node new_node = new Node(new_data);
new_node.next = head;
head = new_node;
}
static boolean detectLoop(Node h)
{
HashSet<Node> s = new HashSet<Node>();
while (h != null) {
if (s.contains(h))
return true;
s.add(h);
h = h.next;
}
return false;
}
public static void main(String[] args)
{
LinkedList llist = new LinkedList();
llist.push(20);
llist.push(4);
llist.push(15);
llist.push(10);
llist.head.next.next.next.next = llist.head;
if (detectLoop(head))
System.out.println("Loop found");
else
System.out.println("No Loop");
}
}

JAVA C OOP DS DBMS Coding & A

TOP
Sort array based on the frequency
METHOD (Use Hashing and Sorting) Using a hashing
mechanism, we can store the elements (also the first index)
and their counts in a hash. Finally, sort the hash elements
according to their counts.

class GFG {
static Integer[] arr = { 2, 5, 2, 8, 5, 6, 8, 8 };
public static void main(String[] args)
{
List<Integer> list = Arrays.asList(arr);
sortBasedOnFrequencyAndValue(list);
}
public static void
sortBasedOnFrequencyAndValue(List<Integer> list)
{
int n = arr.length;
final HashMap<Integer, Integer> mapCount
= new HashMap<Integer, Integer>();
final HashMap<Integer, Integer> mapIndex
= new HashMap<Integer, Integer>();
for (int i = 0; i < n; i++) {
if (mapCount.containsKey(arr[i])) {
mapCount.put(arr[i],
mapCount.get(arr[i]) + 1);
}
else {
mapCount.put(arr[i],1);
mapIndex.put(arr[i],i);
}
Collections.sort(list, new Comparator<Integer>() {
public int compare(Integer n1, Integer n2)
{
int freq1 = mapCount.get(n1);
int freq2 = mapCount.get(n2);
if (freq1 != freq2) {
return freq2 - freq1;
}
else {
return mapIndex.get(n1)
- mapIndex.get(
n2);
}
}
});
System.out.println(list);
}
}

Output - 8 8 8 2 2 5 5 6 -1 9999999

JAVA C OOP DS DBMS Coding & A

TOP
Sort an array by characters.
Method : By using the sort() method 2A By using the sort()
method- natural sorting
Procedure: The main logic is to toCharArray() method of the
String class over the input string to create a character array for
the input string. Now use Arrays.sort(char c[]) method to sort
character array. Use the String class constructor to create a
sorted string from a char array.

import java.util.Arrays;
public class GFG {
public static String sortString(String inputString)
{
char tempArray[] = inputString.toCharArray();
Arrays.sort(tempArray);
return new String(tempArray);
}
public static void main(String[] args)
{
String inputString = "geeksforgeeks";
String outputString = sortString(inputString);
System.out.println("Input String : " + inputString);
System.out.println("Output String : "
+ outputString);
}
}

JAVA C OOP DS DBMS Coding & A

TOP
find its first non-repeating character
Method #1: HashMap and Two-string method traversals.

class GFG {
static final int NO_OF_CHARS = 256;
static char count[] = new char[NO_OF_CHARS];
static void getCharCountArray(String str)
{
for (int i = 0; i < str.length(); i++)
count[str.charAt(i)]++;
}
static int firstNonRepeating(String str)
{
getCharCountArray(str);
int index = -1, i;

for (i = 0; i < str.length(); i++) {


if (count[str.charAt(i)] == 1) {
index = i;
break;
}
}

return index;
}
public static void main(String[] args)
{
String str = "geeksforgeeks";
int index = firstNonRepeating(str);

System.out.println(
index == -1
? "Either all characters are repeating or string "
+ "is empty"
: "First non-repeating character is "
+ str.charAt(index));
}
}

JAVA C OOP DS DBMS Coding & A


TOP
Find Kth smallest element in an array.
Sorted array. : Sort the input array in the increasing order
Return the element at the K-1 index (0 – Based indexing) in the
sorted array

class GFG {
public static int kthSmallest(Integer[] arr, int K)
{
Arrays.sort(arr);
return arr[K - 1];
}
public static void main(String[] args)
{
Integer arr[] = new Integer[] { 12, 3, 5, 7, 19 };
int K = 2;
System.out.print("K'th smallest element is "
+ kthSmallest(arr, K));
}
}

While finding the shortest path in a graph which


Algorithm is used BFS or DFS?

BFS can be used to find a single source shortest path in an


unweighted graph because, in BFS, we reach a vertex with a
minimum number of edges from a source vertex. In DFS, we
might traverse through more edges to reach a destination
vertex from a source.

JAVA C OOP DS DBMS Coding & A


TOP

Intro -

My name is Nikhil Raghuwanshi. I am a native of central


India Bhopal MP. I have done my Btech from Sagar Institute
of Research & Technology with overall 8.01 cgpa in the
computer science branch. Coming to my technical skills
aspect, I am proficient in core java and frontend, also I am
having an youtube channel and frontend tutotrial website
and my hobby is wildlife photgraphy. Thats all.

Q1 . Will there be any issue in switching to technologies that you


don’t know, about for any project that we assign?

No , there will be no issues because as a fresher I want to explore more


technology and want to enhance my skills.

Q2. How long are you planning to work for Infosys, is it for a short
duration?

No , it's not like that , As a fresher I want to work on at least 2-3 client
project in Infosys so that it will be beneficial for my career growth.
Q3 . Any plans for higher studies?

Actually there is no plans for higher studies right now

Q4. What if in a project you have to work alone with no help


available, will you be able to do it and learn technologies
according to that?

Yes , I will do it because I believe in self learning and that is also


helpful for enhancing my technical knowledge

Q5. Why Join Infosys

My educational qualifications are matching to your company


recruitment. I need a platform to establish my career. Your
company is a well-reputed company. Here I can grow up my skills,
knowledge and learn new things and utilize my knowledge which
will be helpful for me in my future.

JAVA C OOP DS DBMS Coding & A

TOP
Project -

So our project is basically made to help out the people suffering


from depression and anxiety and taking wrong steps in there
lives.

Our project is a fully web based project

It was a group project and we were 4 members in that grp

My part was frontend work

So it was like if you are suffering from depression or any type of


anxiety and want to overcome that you can write a story of your
own here and ask for suggestions

You can post your story either publically or privately

If you are mainly your story public anyone can access it and
give there suggestions about how they were able to overcome
that same thing as well as a professional will be watching and
giving their advices too

Now if you that story contains any private details or you dont
want anyone to read that you can make it private

By making it private only specialists of. That condition will be


able to see as well as give suggestions

JAVA C OOP DS DBMS Coding & A

TOP

You might also like