Archive for March, 2012

DOS-Basics.

Posted: March 31, 2012 in DOS
  • To access a folder within the parent directory

           SYNTAX: cd directory_name 

  • To get back to the previous parent directory

           SYNTAX: cd ..

  • To make a directory

           SYNTAX: md directory_name

  • To delete a specific file

          SYNTAX: del filename.type

  • Killing a process

            SYNTAX: tskill processname

  • Copy a file 

           SYNTAX: copy “filename.type”  “destiantion_folder”

 

import java.util.*;
class StackDemo {
static void showpush(Stack st, int a) {
st.push(new Integer(a));
System.out.println(“push(” + a + “)”);
System.out.println(“stack: ” + st);
}
static void showpop(Stack st) {
System.out.print(“pop -> “);
Integer a = (Integer) st.pop();
System.out.println(a);
System.out.println(“stack: ” + st);
}
public static void main(String args[]) {
Stack st = new Stack();
System.out.println(“stack: ” + st);
showpush(st, 42);
showpush(st, 66);
showpush(st, 99);
showpop(st);
showpop(st);
showpop(st);
try {
showpop(st);
} catch (EmptyStackException e) {
System.out.println(“empty stack”);
}
}
}

 

<?php
echo ‘<b>SERVER DOMAIN-NAME:</b>’;
echo $_SERVER[‘SERVER_NAME’];
echo ‘<br><br><b>YOUR IP-ADDRESS IS:</b>’;
echo $_SERVER[‘REMOTE_ADDR’];
echo ‘<br><br><b>SERVER-PORT USED:</b>’;
echo $_SERVER[‘SERVER_PORT’];
echo ‘<br><br><b>SERVER SOFTWARE:</b>’;
echo $_SERVER[‘SERVER_SOFTWARE’];
echo ‘<br><br><b>CLIENT BROWSER DETAILS:</b>’;
echo $_SERVER[‘HTTP_USER_AGENT’];
echo ‘<br><br><b>REQUEST METHOD:</b>’;
echo $_SERVER[‘REQUEST_METHOD’];
echo ‘<br><br><b>SERVER-PROTOCOL USED:</b>’;
echo $_SERVER[‘SERVER_PROTOCOL’];
?>

Inheritance in Interface

Posted: March 23, 2012 in Java Programs

interface one
{
void show();
}
interface two
{
void display();
}
class inherit implements two
{
public void show()
{
System.out.println(“Show method called”);
}
public void display()
{
System.out.println(“Display method called”);
}
}
class inter2
{
public static void main(String g[])
{
inherit i=new inherit();
i.show();
i.display();
}
}

Interface

Posted: March 23, 2012 in Java Programs

interface display
{
void show();
}
class showing implements display
{
public void show()
{
System.out.println(“Show method is being called”);
}
}
class inter1
{
public static void main (String g[])
{
showing i=new showing();
i.show();
}
}

 

import java.util.*;
class LinkedListDemo {
public static void main(String args[]) {
// create a linked list
LinkedList ll = new LinkedList();
// add elements to the linked list
ll.add(“F”);
ll.add(“B”);
ll.add(“D”);
ll.add(“E”);
ll.add(“C”);
ll.addLast(“Z”);
ll.addFirst(“A”);
ll.add(2, “A2”);
System.out.println(“Original contents of ll: ” + ll);
// remove elements from the linked list
ll.remove(“F”);
ll.remove(3);
System.out.println(“Contents of ll after deletion: ”
+ ll);
// remove first and last elements
ll.removeFirst();
ll.removeLast();
System.out.println(“ll after deleting first and last: ”
+ ll);
// get and set a value
Object val = ll.get(3);
ll.set(2, (String) val + ” Changed”);
System.out.println(“ll after change: ” + ll);
}
}

Double Linked List

Posted: March 6, 2012 in Java Programs

import java.util.*;
class Node2
{
int data;
Node2 next,prev;
public Node2(int data)
{
this.data=data;
next=prev=null;
}
}
class DLinkedList
{
private Node2 start=null,last=null;
public boolean empty()
{
if(start==null)
return true;
else
return false;
}
public void create(int n)
{
Node2 p,q;
for(int i=0;i<n;i++)
{
Scanner src=new Scanner(System.in);
System.out.println(“Enter data”);
int ele=src.nextInt();
p=new Node2(ele);
if (start==null)
start=last=p;
else
{
last.next=p;
p.prev=last;
last=p;
}
}
}
public void insertBeg(int ele)
{
Node2 p=new Node2(ele);
if(start==null)
start=last=p;
else
{
p.next=start;
start.prev=p;
start=p;
}
}
public void insertEnd(int ele)
{
Node2 p=new Node2(ele);
if(last==null)
start=last=p;
else
{
p.prev=last;
last.next=p;
last=p;
}
}
public void insertPos(int ele,int pos)
{
Node2 p,q=start;
p=new Node2(ele);
for(int i=0;i<pos-2;i++)
q=q.next;
p.next=q.next;
p.prev=q;
q.next=p;
p.next.prev=p;
}
public int deleteBeg()
{
Node2 p=start;
if(start==last)
start=last=null;
else
start=start.next;
return p.data;
}
public int deleteEnd()
{
Node2 p=last,q;
if(start==last)
start=last=null;
else
{
q=last.prev;
q.next=null;
last=q;
}
return p.data;
}
public int deletePos(int pos)
{
Node2 p,q=start;
for(int i=0;i<pos-2;i++)
q=q.next;
p=q.next;
q.next=p.next;
p.next.prev=q;
return p.data;
}
public void deleteEle(int ele)
{
Node2 p,q=start;
while(q!=null)
{
if(q.data==ele)
break;
q=q.next;
}
if(q==null)
System.out.println(ele+” is not found”);
else
{
System.out.println(ele+” is deleted”);
if(q==start)
{
start=start.next;
start.prev=null;
}
else
{
p=q.prev;
p.next=q.next;
q.next.prev=p;
}
}
}
public void display()
{
Node2 q=start;
while(q!=null)
{
System.out.print(q.data+” “);
q=q.next;
}
System.out.println();
}
public void revdis()
{
Node2 q=last;
while(q!=null)
{
System.out.print(q.data+” “);
q=q.prev;
}
System.out.println();
}
}
class DLLExp
{
public static void main(String g[])
{
int ch,pele;
Scanner src=new Scanner(System.in);
DLinkedList obj=new DLinkedList();
System.out.println(“Enter no of elements to create”);
int n=src.nextInt();
obj.create(n);
while(true)
{
System.out.println(“System choice 1:insert Beg 2:Insert End”);
System.out.println(“3:insert pos 4:delete beg 5:delete end 6:delete pos”);
System.out.println(“7:delete element 8:display 9:Reverse display 10:exit”);
ch=src.nextInt();
if(ch==10)
break;
switch(ch)
{
case 1:
System.out.println(“enter the element to instert”);
int ele=src.nextInt();
obj.insertBeg(ele);
break;
case 2:
System.out.println(“enter the element to instert”);
ele=src.nextInt();
obj.insertEnd(ele);
break;
case 3:
System.out.println(“enter the element to instert”);
ele=src.nextInt();
System.out.println(“enter the position”);
int pos=src.nextInt();
obj.insertPos(ele,pos);
break;
case 4:
if(obj.empty())
System.out.println(“doubly linked list is empty”);
else
{
pele=obj.deleteBeg();
System.out.println(“Deleted element is “+pele);
}
break;
case 5:
if(obj.empty())
System.out.println(“doubly linked list is empty”);
else
{
pele=obj.deleteEnd();
System.out.println(“Deleted element is “+pele);
}
break;
case 6:
if(obj.empty())
System.out.println(“doubly linked list is empty”);
else
{
System.out.println(“enter the position”);
pos=src.nextInt();
pele=obj.deletePos(pos);
System.out.println(“Deleted element is “+pele);
}
break;
case 7:
if(obj.empty())
System.out.println(“doubly linked list is empty”);
else
{
System.out.println(“enter element to delete”);
ele=src.nextInt();
obj.deleteEle(ele);
}
break;
case 8:
if(obj.empty())
System.out.println(“doubly linked list is empty”);
else
obj.display();
break;
case 9:
if(obj.empty())
System.out.println(“doubly linked list is empty”);
else
obj.revdis();
}
}
}
}