Probationary officer(Software) at Duth-Bangla Bank Ltd_2016
Exam Taker : BUET
Q-1.Write
down time complexities of different sorting algorithm.
Ans:
Algorithm |
Time Complexity |
||
Best |
Average |
Worst |
|
Selection
Sort |
Ω(n^2) |
θ(n^2) |
O(n^2) |
Ω(n) |
θ(n^2) |
O(n^2) |
|
Ω(n) |
θ(n^2) |
O(n^2) |
|
Ω(n log(n)) |
θ(n log(n)) |
O(n log(n)) |
|
Ω(n log(n)) |
θ(n log(n)) |
O(n^2) |
|
Ω(n log(n)) |
θ(n log(n)) |
O(n log(n)) |
|
Ω(n+k) |
θ(n+k) |
O(n^2) |
|
Ω(nk) |
θ(nk) |
O(nk) |
Q-2.What
is Trigger ?write
a code for auto increment sequence and trigger.
Ans: Trigger: A trigger is a stored procedure in database which automatically invokes whenever a special event in the database occurs. For example, a trigger can be invoked when a row is inserted into a specified table or when certain table columns are being updated.
Syntax:
create trigger [trigger_name
[before | after]
{insert | update | delete}
on [table_name]
[for each row]
[trigger_body]
Auto increment Sequence using Trigger
CREATE TABLE test ( ID NUMBER NOT NULL, DESCRIPTION VARCHAR2(30) NOT NULL); ALTER TABLE test ADD ( CONSTRAINT test_pk PRIMARY KEY (ID)); CREATE SEQUENCE test_seq; CREATE OR REPLACE TRIGGER test_insert BEFORE INSERT ON test FOR EACH ROW BEGIN SELECT test_seq.NEXTVAL INTO :new.id FROM dual; END; |
Q-3.Table
definition
Ans:CREATE TABLE Persons (
PersonID int,
LastName varchar(255),
FirstName varchar(255),
Address varchar(255),
City varchar(255)
);
Q-4.Sequence
definition
Ans: A sequence is a user defined schema bound object that generates a sequence of numeric values.
CREATE SEQUENCE sequence_name
START WITH initial_value
INCREMENT BY increment_value
MINVALUE minimum value
MAXVALUE maximum value
CYCLE|NOCYCLE ;
Q-5.Trigger
Definition
Ans: CREATE [OR REPLACE ] TRIGGER trigger_name
{BEFORE | AFTER | INSTEAD OF }
{INSERT [OR] | UPDATE [OR] |
DELETE}
[OF col_name]
ON table_name
[REFERENCING OLD AS o NEW AS n]
[FOR EACH ROW]
WHEN (condition)
DECLARE
Declaration-statements
BEGIN
Executable-statements
EXCEPTION
Exception-handling-statements
END;
Q-6.What
is the difference among string, string buffer and string builder ?
Ans:
String |
String buffer |
String builder |
Immutable
object |
Mutable |
Mutable |
Thread
Safe |
No
thread safe |
Thread
Safe |
Performance
fast |
StringBuffer
is less efficient than StringBuilder |
StringBuilder
is more efficient than StringBuffer |
Syntax:
String Str=”binary ” ; |
StringBuffervar=
new StringBuffer(str) ; |
StringBuildervar=
new StringBuilder(str) ; |
Q-7.write
of palindrome in Java or C++
Ans:
class PalindromeExample{
public static void main(String args[]){
int r,sum=0,temp;
int n=454;//It is the number variable to be checked for palindrome
temp=n;
while(n>0){
r=n%10; //getting remainder
sum=(sum*10)+r;
n=n/10;
}
if(temp==sum)
System.out.println("palindrome number ");
else
System.out.println("not palindrome");
Q-8.What
is method overloading and method overriding?
ans:
Method overloading |
Method overriding |
Method
overloading is a compile time polymorphism. |
Method
overriding is a run time polymorphism. |
In
case of method overloading, parameter must be different. |
In
case of method overriding, parameter must be same. |
Method
overloading is used to increase the readability of the
program. |
Method
overriding is used to provide the specific implementation of
the method that is already provided by its super class. |
It
is occur within the class. |
While it is performed in two
classes with inheritance relationship. |
|
While
method overriding always needs inheritance. |
Overloaded methods use static
binding. |
Overridden
methods use dynamic binding. |
You can perform overloading on
static methods. |
You
cannot perform overriding on static methods. |
Q-9.What
is the difference between implementing runnable interfaces and extend thread
class ?
Ans:
Implements
Runnable ":
public
class RunnableExample implements Runnable
{
public
void run() {
System.out.println("Alive
is awesome");
}
}
extends
Thread:
public
class ThreadExample extends Thread {
public
void run() {
System.out.println("
Love Yourself ");
}
}
Implements
Runnable Extends Thread
Inheritance option |
extends any java class |
No |
Reusability |
Yes |
No |
Object Oriented Design |
Good,allows composition |
Bad |
Loosely Coupled |
Yes |
No |
Function Overhead |
No |
Yes |
Q-10.Given
two tables are employees (id, name, salary, dept_id) and department (dept_id,
dept_name), write SQL to find MAX salary and AVERAGE Salary for specific
department.
Ans:
Select dept_name,
max(salary) as max_salary
from
employees, department
where
employees.dept_id=department.dept_id
group by dept_name ;
AVERAGE
Salary
select dept_name,
avg(salary) as avg_salary
from
employees, department
where
employees.dept_id=department.dept_id
group bydept_name
;
Q-11.
Write a Java program based on the following conditions: There is one Circle
class and one cylinder class. Circle class has an area function.cylinder class
has to calculate the circle area at the base and height of its own ( Cylinder
area=circle area*height).use inheritance to calculate area of cylinder.
Ans:
importjava.lang.Math.*;
class
Circle
{
double area(double r)
{
returnMath.PI*r*r;
}
}
class
cylinder extends Circle
{
void area(double height, double
base)
{
System.out.print("Area
of cylinder: "+ super.area(base)*height);
}
}
public
class Solution_12
{
public static void main(String
args[])
{
cylinderobj = new cylinder();
obj.area(3.0,2.0);
}
}
Q-12.Explain
BFS Traversal of a graph with an example
BFS
algorithm starts the operation from the first or starting node in a graph and
traverses it thoroughly. Once it successfully traverses the initial node, then
the next non-traversed vertex in the graph is visited and marked.
Hence, you can say that all the nodes adjacent to the current vertex are visited and traversed in the first iteration. A simple queue methodology is utilized to implement the working of a BFS algorithm, and it consists of the following steps:
0 মন্তব্যসমূহ