Custom Search

Sunday 16 September 2012

Java Program to explain randomaccessfile class, Write an application that that use randomaccessfile class


Java Program to explain  randomaccessfile class, Write an application that that use randomaccessfile class

Program
import java.io.*;

class Tail
{
public static void main(String args[])
{
try
{
RandomAccessFile raf=new RandomAccessFile(args[0], "r");

long count=Long.valueOf(args[1]).longValue();

long position=raf.length();

position-=count;
if(position<0)
position=0;

raf.seek(position);

while(true)
{
try
{
byte b=raf.readByte();

System.out.print((char)b);

}
catch(EOFException eofe)
{
break;
}
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
}

Friday 14 September 2012

Whai is Degree of a Relationship Set in Datanase Management System(DBMS)?, What is binart, ternary & n-ary relationship?

Whai is Degree of a Relationship Set in Datanase Management System(DBMS)?, What is binary, ternary & n-ary relationship?

Definition
Degree of Relationship Set refers to number of entity sets that participate in a relationship
set.
1) Relationship sets that involve two entity sets are binary (or degree two). Generally, most relationship sets in a database system are binary.
2) Relationship sets may involve more than two entity sets.
E.g. Suppose employees of a bank may have jobs
(responsibilities) at multiple branches, with different jobs at
different branches. Then there is a ternary relationship set
between entity sets employee, job and branch
3) Relationships between more than two entity sets are rare. Most
relationships are binary. 

Binary Vs. Non-Binary Relationships
 Some relationships that appear to be non-binary may be better
represented using binary relationships
 E.g. A ternary relationship parents, relating a child to his/her father and
mother, is best replaced by two binary relationships, father and mother
 Using two binary relationships allows partial information (e.g. only
mother being know)
 But there are some relationships that are naturally non-binary
 E.g. works-on

Thursday 13 September 2012

Define Relationship & Relationship Set in Database Management System(DBMS)

Ques:- Define Relationship & Relationship Set in Database Management System(DBMS)

Answer: A relationship is an association among several entities
Example:
Hayes  
customer entity 

depositor
relationship set

A-102
account entity

A relationship set is a mathematical relation among n >=2 entities,each taken from entity sets
{(e1, e2, … en) | e1 belongs to E1, e2 belongs to E2, …, en belongs to En}
where (e1, e2, …, en) is a relationship

 Example:
(Hayes, A-102) belongs to depositor 



=>>An attribute can also be property of a relationship set.
=>> For instance, the depositor relationship set between entity sets
customer and account may have the attribute access-date

Wednesday 12 September 2012

Java Program for an application that explain super keywords, WAP in Java for super keywords


Java Program for an application that explain super keywords, WAP in Java for super keywords

Program
class base
{
int i;
base(int a)
{
i=a;
}
void show()
{
System.out.println("Base:"+i);
}

}
class derived extends base
{
int i,j;
derived(int a,int b,int c)
{
super(a);
i=b;
j=c;
}
void show()
{
super.show();
System.out.println("Base i:"+super.i);
System.out.println("Derived i:"+i);
System.out.println("Derived j:"+i);
}

}
class superEx
{
public static void main(String args[])
{
derived d = new derived(10,20,30);
d.show();
}
}

Monday 3 September 2012

Write a linux Shell Script to find Greatest and Smallest number in an Array, shell script for maximum & minimum value

Write a linux Shell Script to find Greatest and Smallest number in an Array, shell script for maximum & minimum value


Program
echo "please enter size of an array"
read n

#for loop for taking input from user
for((i=0;i<n;i++))
do
echo " enter $((i+1)) number"
read nos[$i]
done

#for loop for printing the entered number
echo "number entered are"
for((i=0;i<n;i++))
do
echo ${nos[$i]}
done

#main loop
small=${nos[0]}
greatest=${nos[0]}
for((i=0;i<n;i++))
do
#logic for smallest number
if [ ${nos[$i]} -lt $small ]; then
small=${nos[$i]}

#logic for greatest number
elif [ ${nos[$i]} -gt $greatest ]; then
greatest=${nos[$i]}
fi
done

#printing smallest and greatest number

echo "smallest number in an array is $small"
echo "greatest number in an array is $greatest"

Write a linux program in Shell Script to count number of files in a directory


Write a linux program in Shell Script to count number of files in a directory


Program
echo "enter the complete path of your directory"
read n
if [ -z $n ]; then
#print number of files in current directory
ls -l | grep "^-" | wc -l
fi
#first check whether directory exist or not
test -d "$n" && echo -e "number of files in $n is `ls -l $n | grep "^-" | wc -l`\n" || echo -e "not a directory\n"

Write a Linux shell script for Insertion Sort, Write a program in pl/sql program for insertion sorting


Write a Linux shell script for Insertion Sort, Write a program in pl/sql program for insertion sorting


Program

echo "please enter the number"
read n
echo "please enter number in an array"
for((i=0;i<n;i++))
do
read arr[$i]
done

#logic for insertion sort

for((i=1;i<n;i++))
do
j=$i-1
temp=${arr[$i]}
while((j>=0 && arr[j]>temp))
do
arr[$j+1]=${arr[$j]}
j=$j-1
done
arr[j+1]=$temp
done

#printing sorted array

echo "printing sorted array"
for((i=0;i<n;i++))
do
echo ${arr[$i]}
done




Click here to check the output

Write a Linux shell script for Selection Sort, Write a program in pl/sql program for sorting


Write a Linux shell script for Selection Sort, Write a program in pl/sql program for sorting


Program
echo "please enter the number"
read n
echo "please enter number an array"
for((i=0;i<n;i++))
do
read arr[$i]
done

#process for selection sort

for((i=0;i<n-1;i++))
do
small=${arr[$i]}
index=$i
for((j=i+1;j<n;j++))
do
if((arr[j]<small))
then
small=${arr[$j]}
index=$j
fi
done
temp=${arr[$i]}
arr[$i]=${arr[$index]}
arr[$index]=$temp
done

#printing sorted array

echo "printed sorted array is:"
for((i=0;i<n;i++))
do
echo ${arr[$i]}
done

Click here to check the output

Write a linux Shell Script to swap two numbers without using third variable, Swapping in shell script


Write a linux Shell Script to swap two numbers without using third variable, Swapping in shell script


Program
echo "please enter first number"
read a
echo " please enter second number"
read b
echo " value of a before swapping is $a and value of b before swapping is $b"

#swapping
a=$((a+b))
b=$((a - b))
a=$((a-b))

echo "value of a after swapping is $a and value of b after swapping is $b"

Laptops