Combined 4 Banks Assistant Programmer Written Exam 2020 Question Full Solution
1. 1. Difference between spoofing and sniffing
Packet spoofing |
Packet sniffing |
Packet
sniffing refers to listening to other's conversation. |
Packet
sniffing refers to listening to other's introducing
fake network traffic pretending to be someone else. |
It is
a passive attack (i.e. attacker cannot cause
any kind of damage) |
It is
an active attack (i.e. attacker can insert malicious program to infect the
other system) |
Packet
sniffing is usually done by gaining access to a computer/device through which
the traffic flows (e.g. router or admin-PC) |
Packet
spoofing is done by sending packets with incorrect source address. The
receiver the sends reply to this forged(spoofed) address. (Modifying routing
tables) |
Encryption
is the best method to tackle sniffing |
Digital
signatures is a good method to tackle spoofing |
2. 2. What
is the full meaning of SQL? Make list of the aggregate functions. Write SQL
Query of a table and its output.
Answer:
SQL
stands for Structured Query Language. SQL became a standard of the American National
Standards Institute (ANSI) in 1986 and of the International Organization for Standardization
(ISO) in 1987.
The
most commonly used SQL aggregate functions:
AVG
- calculates the average of a set of values.
COUNT
- counts rows in a specified table or view.
MIN
- gets the minimum value in a set of values.
MAX
- gets the maximum value in a set of values.
SUM
- calculates the sum of values.
SQL
Query for a table
CREATE TABLE persons (
id INT NOT NULL PRIMARY KEY AUTO
INCREMENT,
name VARCHAR (50) NOT NULL,
birth date DATE,
phone VARCHAR (15) NOT NULL
UNIQUE
);
TABLE:
person
id |
name |
birth_date |
Output: |
101 |
Alina |
11/11/2011 |
01725402592 |
102 |
Bobi |
12/12/2012 |
01516102973 |
103 |
Robbi |
07/07/2007 |
01516102930 |
3. What
will be the output in C and java code?
Output: |
5 |
3 |
2 |
1 |
5 |
38 |
2 |
6356864 |
4198653 |
(i) C
program:
#include<stdio.h>
int main() {
int a[] = {5,3,4,2,1);
int i;
for(i=0; i<10; i++)
printf("%d\n", a[i]);
}
(ii)Java
program:
public class MyFirst {
public static void main(String[]
args) {
MyFirst obj new MyFirst (n);
}
static int a = 10;
static int n;
int b = 5;
int C;
public My First (int m) {
System.out.println(a+",
"+ b+", " + C + ", " + n + ",
" + m);
}
{
b = 30;
n = 20;
}
static{
a = 60;
}
}
Answer:
60, 30,
0, 20, 0
4.
What is Agile Methodology? Difference between Agile Model and Waterfall Model
Answer:
Agile Methodology: AGILE
methodology is a practice that promotes continuous iteration of development and
testing throughout the software development lifecycle of the project. In the Agile
model, both development and testing activities are concurrent, unlike the
Waterfall model.
Agile and Waterfall model are two different methods for software development process.
Agile Model |
Waterfall Model |
Agile
method proposes incremental and iterative approach to software design |
Development
of the software flows sequentially from start point to end point. |
The
agile process is broken into individual models that designers work on |
The
design process is not broken into an individual models |
Agile
model is considered unstructured compared to the waterfall model |
Waterfall
model are more secure because they are so plan oriented |
Documentation
attends less priority than software development |
Documentation
is a top priority and can testing phase is executed because separate parts
are not fully functional. |
Testers
and developers work together |
Testers
work separately from developers |
At the
end of every sprint, user acceptance is performed |
User
acceptance is performed at the end of the project. |
5. Linked list, doubly linked list and circular linked list explain with diagram.
Answer:
Singly link list: In a singly linked list, each
node stores a reference to an object that is anelement of the sequence, as well
as a reference to the next node of the list. It does not storeany pointer or
reference to the previous node.
Examples
Let us
assume the singly linked list above and trace down the effect of each fragment
below.The list is restored to its initial state before each line executes
head=head.next;
head.next=head.next.next;
Doubly
link list:
Doubly
Linked List is a variation of Linked list in which navigation is possible in
both ways,both forward and backward easily as compared to Single Linked List.
Following are theimportant terms to understand the concept of doubly linked
list.
Link: Each link of a linked list can
store a data called an element.
Next: Each link of a linked list
contains a link to the next link called Next.
Prev: Each link of a linked list
contains a link to the previous link called Prev.
Linked
List: A Linked
List contains the connection link to the first link called First andto the last
link called Last.
Doubly
Linked List Representation
As per
the above illustration, following are the important points to be considered.
Doubly
Linked List contains a link element called first and last.
Each
link carries a data field(s) and two link fields called next and prev.
Each
link is linked with its next link using its next link.
Each
link is linked with its previous link using its previous link.
The
last link carries a link as null to mark the end of the list.
Circular
link list:
Circular
linked list is a linked list where all nodes are connected to form a circle.
There is no NULL at the end. A circular linked list can be a singly circular
linked list or doubly circular linked list.
6. X is an integer stream of N
numbers. You have to select 2 data P and Q such thatA<= (P+Q) <=B. Write
an algorithm / pseudo code/ C program how many ways youcan select P & Q.
The time complexity must be n log n.
Answer:
#include<stdio.h>
#include<stdlib.h>
int
x [] = {3,4,1,2,5,6,4,7,10,8}; // X is an
N
numbers
int
N = 10; //
}
int
compare (const void * a, const void * b) {
return
(* (int*) a - *(int*)b);
}
int
main() {
qsort
(X, N, sizeof(int), compare);
int
i, P, Q;
int
ans = 0;
int
A 5;
int
B = 10;
int
left_border=N, right_border=-1;
int
begin, end, mid;
for
(i = 0; i<n; i++) {
right
border = -1;
//binary
search begin
begin=
i+1;
end
N-1;
while
(begin<end) {
mid
= (begin + end) /2;
P=X[i];
Q=
X[mid];
if
(P+Q>=A && P+Q<=B) {
begin
mid + 1;
if
(begin>right_border) {
right_border=mid;
}
}
else{
end
= mid - 1;
}
}
//binary
search end
left
border = N;
begin=
i+1;
end
N-1;
//
binary search begin
while
(begin<end) {
mid
= (begin + end)/2;
P
= X[i];
Q=
X[mid] ;
if
(P+Q>=A && P+Q<=B) {
end
= mid;
if
(end<left_border) {
left
border = mid;
}
}
else{
end
= mid - 1;
}
}
//
binary search end
if
(left_border!=N &&right_border!= -1) {
ans
=ans + (right_border - left_border) + 1;
}
printf
("ways you can select P & Q = %d ", ans);
}
Output:
ways you
can select P & Q =21
7. How to determine the weighted graph has negative cycle?
Answer:
We are given a directed graph. We
need compute whether the graph has negative cycle ornot. A negative cycle is
one in which the overall sum of the cycle comes negative.
Negative weights are found in
various applications of graphs. For example, instead of payingcost for a path,
we may get some advantage if we follow the path.
Examples:
Input:
4 4
0 1 1
1 2 -1
2 3 -1
30 -1
Output:
Yes
The
graph contains a negative cycle.
Below
is algorithm find if there is a negative weight cycle reachable from given
source.
1.
Initialize
distances from source to all vertices as infinite and distance to source itself
as 0. Create an array dist[] of size V| with all values as infinite except
dist[src] wheresrc is source vertex.
2.
This step calculates shortest distances. Do
following (V|-1 times where [V] is the numberof vertices in given graph.
a. Do following for each edge u-V
……………………….. If dist[v]
>dist[u] + weight of edge uv, then update dist[v]
……………….........dist[v]
= dist[u] + weight of edge uv
3.
This
step reports if there is a negative weight cycle in graph. Do following for
each edgeU-V ......If dist[v] >dist[u] + weight of edge uv, then “Graph
contains negative weightcycle"
The
idea of step 3 is, step 2 guarantees shortest distances if graph doesn't
contain negativeweight cycle. If we iterate through all edges one more time and
get a shorter path for anyvertex, then there is a negative weight cycle.
8. Write down the functionality of OSI model.
Answer:
The OSI
model is a layered framework for the design of network systems that allows
communication between all types of computer systems. It consists of seven
separate but related layers, each of which defines a part of the process of
moving information across network. There are 7 layers in OSI model is given
below:
Layer 7:
Application.
Layer 6:
Presentation.
Layer 5:
Session.
Layer 4:
Transport.
Layer 3:
Network.
Layer 2:
Data Link.
Layer 1:
Physical.
Physical Layer: The physical layer, the lowest
layer of the OSI model, is concerned with the transmission and reception of the
unstructured raw bit stream over a physical medium. It describes the electrical/optical,
mechanical and functional interfaces to the physical medium and carries the
signals for all of the higher layers.
Data Link Layer: The data link layer provides
error-free transfer of data frames from one node to another over the physical
layer, allowing layers above it to assume virtually error-free Transmission
over the link.
Network
Layer: The
network layer controls the operation of the subnet. A key design issue is determining
how packets are routed from source to destination.
Transport
Layer: The
transport layer ensures that messages are delivered error-free, insequence and
with no losses or duplications. It relieves the higher layer protocols from
anyconcern with the transfer of data between them and their peers.
Session Layer: The session layer allows users
on different machines to establish sessions between them. This layer is
responsible for establishing the process-to-process communication between the
hosts in the network.
Presentation
Layer: The
Presentation layer is responsible for protocol conversion, data encryption/decryption,
Expanding graphics command and the date compression.
Application
layer: The
application layer serves as the window for users and application processes to
access network services. The application layer is the OSI layer, which is closest
to the end-user. It means OSI application layer allows users to interact with
other software application. This layer contains a variety of commonly needed
functions:
Resource
sharing and device redirection
Remote
file access
Remote
printer access
Inter-process
communication
Network
management
Directory
services
Electronic
messaging (such as mail)
Network
virtual terminals
9.
Write a code in C/C++ that will output the 2nd largest number. (If N>=1)
Answer:
#include <iostream>
using namespace std;
int main() {
int n, num [50], largest, second;
cout<<"Enter number of
elements: ";
cin>>n;
for (int i=0; i<n; i++) {
cout<<"Enter Array
Element"<<(i+1)<<": ";
cin>>num [i];
if (num [0]<num [1]) {
largest
num[1];
second = num [0];
}
else{
largest = num [0];
second = num [1];
}
for (int i = 2; i<n; i++) {
if (num[i] > largest) {
second = largest;
largest = num[i];
}
else if (num[i] > second
&& num[i] != largest) {
second = num[i];
}
}
cout<<"Second Largest
Element in array is: "<<second;
return 0;
}
Output:
Enter number of elements: 5
Enter Array Elementi: 12
Enter Array Element2: 31
Enter Array Element3: 9
Enter Array Element4: 21
Enter Array Element5: 3
Second Largest Element in array
is: 21
10.
Draw ER diagram (Self test)